Thursday, April 16, 2009

Linux, Ubuntu, and File Permissions

For the last week or so, I have been getting more and more comfortable with Ubuntu. I have pretty much figured out the package manager Synaptic and how to install new programs onto my wonderful non-Windows machine.

During installation of any new software through Synaptic, Ubuntu asks for the root password of the machine to actually do the installing. I guess this is a precaution to disallow any other user from installing software that is not meant to be on the machine. Which is a great feature so my wife doesn't muck up my new machine.

I guess Ubuntu by default creates two user accounts during installation which are one user account and one admin account (user root). So apparently when I am playing games and cruising the web, I am actually in my user account and not in the root account. From my readings, Ubuntu does this to protect us from completely screwing up our system, having software inadvertently downloaded to our machine, and/or accidently altering our settings.

For each user, Ubuntu sets up a directory called "/home" which is like a "My Documents" folder on a Windows OS. In this directory the user has full read, write, and execute permissions for every file. Nothing new there.... I am still doing ok.

But.... Everything outside of that directory is "owned" by the root user. And to modify, or execute a file in most every other directory you will need to either change the directory permissions, login as root, or use the "sudo" command which stands for "super user do".

So for instance if I wanted to edit a config file in the /usr/bin using gedit then would have to use the command "sudo gedit" + the filename.

I ran into this issue when trying to install Xampp (which is a web server) into the /opt directory which was owned by root. The solution that I came up with was to use the "chmod" command to set the permission of the new directory, /opt/lampp, so that all users could use it. The actual command I used to do this was "sudo chmod 777 /opt/lampp". The 777 part of this command gives the owner, group, and everyone else the privileged to read,write, and execute the files in the directory.

I know that I most like made some Linux gurus cringe by setting the permissions to 777, but really I am the only person to using this machine so I am not horrified about it. Of course I am always willing to hear about other permission based solutions. So drop me a line if you have a better way of doing things.

Even though I ran into this issue and it took me a little time to figure out... this file permission thing really does make good sense. I can think of a ton of uses for it and as soon as I learn more about "groups" I will setup my system so it is more secure.


  1. If you use the sudo command in the terminal it does not permanantly change the permission of the folder just temporarily makes you the super user.

    I dont really worry too much about permissions and access since I am the only one who uses my computer but you have to be really careful when using the sudo command. I have never experienced anything negative with it.. but typing sudo into the terminal without knowing what you are doing is like playing russian roulete. you may get lucky, or you may completely screw everything up. :)

  2. Did you ever choose a theme !?! Show us.. :)

    I dont know if you know or not but to take a screen shot go to Appications -> Accessories -> Take Screenshot

    would love to see what the desktop of a liberated linux user looks like ;)