{"id":2523,"date":"2012-01-17T15:56:51","date_gmt":"2012-01-17T21:56:51","guid":{"rendered":"http:\/\/icesquare.com\/wordpress\/?p=2523"},"modified":"2012-02-13T13:55:38","modified_gmt":"2012-02-13T19:55:38","slug":"how-to-clean-up-reset-user-account-to-default-on-linux-ubuntu-fedora-automatically","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/how-to-clean-up-reset-user-account-to-default-on-linux-ubuntu-fedora-automatically\/","title":{"rendered":"How to Clean Up \/ Reset User Account To Default on Linux, Ubuntu, Fedora Automatically"},"content":{"rendered":"<style>\nh2 {\nmargin-top:30px;\"\n}\n<\/style>\n<p><img decoding=\"async\" data-attachment-id=\"2524\" data-permalink=\"https:\/\/icesquare.com\/wordpress\/how-to-clean-up-reset-user-account-to-default-on-linux-ubuntu-fedora-automatically\/400px-broom_icon\/#main\" data-orig-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon.png\" data-orig-size=\"400,400\" data-comments-opened=\"1\" data-image-title=\"Clean Up\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon.png\" class=\"alignleft size-medium wp-image-2524\" src=\"\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon.png\" alt=\"\" width=\"200\" srcset=\"https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon.png 400w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-150x150.png 150w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-300x300.png 300w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-177x177.png 177w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-35x35.png 35w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-164x164.png 164w, https:\/\/icesquare.com\/wordpress\/wp-content\/uploads\/2012\/01\/400px-broom_icon-185x185.png 185w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>Imagine that you set up a computer at a public location, such as cafe, library, or computer lab in your school, so that any one can use your computer. Most of the time, users mainly use the web browsers for surfing the web, checking the email, or updating the status on social websites etc. At the mean time, they may download some files on your computer, generating a lot of browsing history in your web browsers, accidentally saving their user names\/passwords in the browsers etc. How do you clean up these mess? How do you reset the user account to default automatically?\n<\/p>\n<p>\nFirst, I am assuming that your computer is running Linux, such as Ubuntu, Fedora, Debian etc. It really doesn&#8217;t matter which Linux you use, because most Linux uses the same kernel. The idea describes in this article is applicable to any Linux.<\/p>\n<h2>Idea<\/h2>\n<p>\nLinux and Windows are very very different. Linux has a much better control on the user permissions. For example, if you simply create a standard user on Linux, e.g.,<\/p>\n<pre>\r\nsudo adduser guestuser\r\n<\/pre>\n<p>where this new user, <strong>guestuser<\/strong>, is a standard user only.<\/p>\n<div class=\"alignright\"><\/div>\n<p>If you log in as guestuser, all of the files you create will be stored in your home folder only, i.e., \/home\/guestuser. Unlike Windows, there is no registry or something similar. In the other words, all of your activities are limited within your home folder. If you like to create a file outside your scope, you will need to have the root access. Of course, you won&#8217;t grand the root access to the guest user.<\/p>\n<p>Now you understand that the guest user can only mess around the home directory only (\/home\/guestuser). In order to clean up or reset the user account to default, all you need is to reset this folder to default.<\/p>\n<h2>Setup a Home Directory On Ram Disk<\/h2>\n<p>We are going to implement this idea using ram disk. If you don&#8217;t know anything about ram disk, you can think about it as a usb thumb drive, except that it is a super fast device, and cannot hold any data after each reboot. In the other words, if we set up a the home directory of the guestuser on a ram disk, all of the mess will be gone after each reboot. So here are the steps:<\/p>\n<p>First, we want to create a guestuser first:<\/p>\n<pre>\r\nsudo adduser guestuser\r\n<\/pre>\n<p>This will add a new user into the system and create its home directory. Next, we want to create a ram disk. Before we do it, let&#8217;s find out how much memory you have in your system:<\/p>\n<pre>\r\nfree -m\r\n<\/pre>\n<p>On my machine, I have 2GB (2000 MB) memory in total.<\/p>\n<pre>\r\n             total     used     free   shared  buffers  cached\r\nMem:          1999     1789      209        0      119    1176\r\n-\/+ buffers\/cache:      492     1506\r\nSwap:         3150        0     3150\r\n<\/pre>\n<p>Since I only have 2GB of memory, I want to keep some of them for my system. I think using 512MB for the ramdisk is enough.<\/p>\n<p>To create a ramdisk during the boot, simply modify \/etc\/rc.local<\/p>\n<pre>\r\nsudo nano \/etc\/rc.local\r\n<\/pre>\n<p>And include the following commands:<\/p>\n<p><\/p>\n<pre>\r\n#Create a 512MB ramdisk, and map it to the home directory of the guestuser.\r\nmount -t ramfs -o size=512M ramfs \/home\/guestuser\r\n\r\n\r\n#After the ramdisk is mapped, the directory will be owned by the root.\r\n#We need to modify the permission such that guestuser can access it.\r\nchown -R guest:guest \/home\/guestuser\r\n<\/pre>\n<p>Here are some special notes for different Linux:<\/p>\n<div style=\"margin-left:20px;\">\n<p><strong>Fedora 15<\/strong> or earlier: None<\/p>\n<p><strong>Fedora 16<\/strong>: By default, \/etc\/rc.local is missing. Please refer my another post: <a href=\"\/wordpress\/fedora-16-etc-rc-local\/\" title=\"Fedora 16 \/etc\/rc.local is missing\" alt=\"Fedora 16 \/etc\/rc.local is missing\" target=\"_blank\">Fedora 16 \/etc\/rc.local is missing<\/a>) for details.<\/p>\n<p><strong>Ubuntu<\/strong>: Please include your code before <strong>exit 0<\/strong> command, otherwise it won&#8217;t work, i.e.,<\/p>\n<\/div>\n<pre>\r\n#!\/bin\/sh -e\r\n#\r\n# rc.local\r\n#\r\n# This script is executed at the end of each multiuser runlevel.\r\n# Make sure that the script will \"exit 0\" on success or any other\r\n# value on error.\r\n#\r\n# In order to enable or disable this script just change the execution\r\n# bits.\r\n#\r\n# By default this script does nothing.\r\n\r\nmount -t ramfs -o size=512M ramfs \/home\/guestuser\r\nchown -R guestuser:guestuser \/home\/guestuser\r\n\r\nexit 0\r\n<\/pre>\n<p>After the set up is completed, simply reboot the computer to make the ramdisk effective.<\/p>\n<h2>Testing<\/h2>\n<p>Now, try to log in as the guestuser. You can try to download some files to your home directory; visit some websites; or even change the wallpaper. All of these settings will be stored in your home directory. Next, try to log out the account, restart the computer and log in to your account again. You will notice that everything will be reset to default, i.e., all of your previously downloaded files are gone, wallpaper will be reset to default, the web history is cleared etc.<\/p>\n<p>Enjoy running a clean, maintenance-free workstation.<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine that you set up a computer at a public location, such as cafe, library, or computer lab in your school, so that any one can use your computer. Most <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/how-to-clean-up-reset-user-account-to-default-on-linux-ubuntu-fedora-automatically\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[94,144,6,69],"tags":[48],"class_list":["post-2523","post","type-post","status-publish","format-standard","hentry","category-computer-problems-computer-help-pc-support","category-sever-problem","category-technology","category-troubleshooting-technology","tag-linux"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-EH","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":896,"url":"https:\/\/icesquare.com\/wordpress\/finally-ubuntu-uses-a-more-updated-linux-kernel-than-fedora\/","url_meta":{"origin":2523,"position":0},"title":"Finally, Ubuntu uses a more updated Linux kernel than Fedora","author":"Derrick","date":"October 11, 2010","format":false,"excerpt":"Historically, Ubuntu focuses on the user experience such as beautiful graphical user interface, while Fedora focuses on performance. In the other words, the kernel in Fedora distribution is more up-to-dated. I just upgraded by Ubuntu 10.04 to 10.10 (released on October 10, 2010), I found that the Linux Kernel in\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1927,"url":"https:\/\/icesquare.com\/wordpress\/phphow-to-get-the-number-of-cpu-cores-in-fedora-ubuntu-and-freebsd\/","url_meta":{"origin":2523,"position":1},"title":"[PHP]How to get the number of CPU cores in Fedora, Ubuntu, and FreeBSD","author":"Derrick","date":"December 2, 2011","format":false,"excerpt":"I am working on a PHP application which needs to be deploy to multiple places. One of the variables is the number of CPU core. Since each server has different number of CPU cores, I need to specify the number of CPU core in my application for each server. I\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1511,"url":"https:\/\/icesquare.com\/wordpress\/how-to-clean-up-the-dmesg-message\/","url_meta":{"origin":2523,"position":2},"title":"How to clean up the dmesg message","author":"Derrick","date":"August 24, 2011","format":false,"excerpt":"Recently, I found that my dmesg log are filled of junk. Or I should say it contains lots of errors and complains that I already fix. However, I don't want to reboot the machine to get rid of these error messages. How can I do it? The solution is very\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":705,"url":"https:\/\/icesquare.com\/wordpress\/softlink-symbolic-link-doesnt-work-on-samba-solved\/","url_meta":{"origin":2523,"position":3},"title":"Softlink \/ Symbolic Link doesn&#8217;t work on Samba &#8211; Solved","author":"Derrick","date":"May 6, 2010","format":false,"excerpt":"After upgrading my Samba servers (One is Ubuntu Linux, and the other one on Fedora Linux), I found that I can no longer access the symbolic links \/ soft links from Windows. It keeps returning \"permission error\", \"You don't have permission to access this folder\" etc. I am pretty sure\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":923,"url":"https:\/\/icesquare.com\/wordpress\/freebsd-or-linux\/","url_meta":{"origin":2523,"position":4},"title":"FreeBSD or Linux in 6 Simple Questions","author":"Derrick","date":"February 18, 2016","format":false,"excerpt":"FreeBSD or Linux FreeBSD or Linux (Ubuntu\/RHEL)? This is a very old question. It's like asking iPhone or Android. There is no short answer. It all depends on your situation. To make things easier, I am going to break it down into six simple questions to help you making decision.\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":505,"url":"https:\/\/icesquare.com\/wordpress\/solvedfedora-repository-error-errno-14-pycurl-error-6\/","url_meta":{"origin":2523,"position":5},"title":"[Solved]Fedora Linux Repository Error ([Errno 14] PYCURL ERROR 6)","author":"Derrick","date":"January 4, 2010","format":false,"excerpt":"I was having trouble to update my Fedora Linux system by running sudo yum update. sudo yum update Loaded plugins: presto, refresh-packagekit Error: Cannot retrieve repository metadata (repomd.xml) for repository: fedora. Please verify its path and try again sometimes I see different sets of error: http:\/\/download.fedoraproject.org\/pu...ta\/repomd.xml: [Errno 14] PYCURL ERROR\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"Fedoraproject.org has downed.","src":"\/wordpress\/wp-content\/uploads\/2010\/01\/Fedora-Down-300x217.png","width":350,"height":200},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=2523"}],"version-history":[{"count":37,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2523\/revisions"}],"predecessor-version":[{"id":2682,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/2523\/revisions\/2682"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=2523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=2523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=2523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}