I use my Ubuntu 10.04 LTS instance (via Virtual Box on Windows 7) with a non-root user. I am trying out developing Rails applications and I notice that I need to run some rails commands with sudo. The problem this gives me is some files are created by the root user then, and I cannot edit them via a GNOME window with my logged in user.

What is the correct thing to do here? Should I somehow always login as root? If so how? Is there some way for me to give all files under my home directory (where I do all my Rails work) the correct permissions for all users, so I can edit them with my logged in user via a window?

At the moment I have to resort to opening a file via the command line like this sudo gedit myFile.rb - this is not very sustainable!

Thanks in advance!

3 Answers 3


As mentioned by @mount.cifs the ubuntu file permission page, includes tips on settting sticky & SGID bits etc.

I would suggest routinly change group ownerships and access rights to your folder.

sudo chgrp -R foobar /home/foo/bar

sudo chmod -R g+w /home/foo/bar

Other than that investigating if setting the umask for your session to group writable will solve you problem?



Ps. I would strongly suggest not setting this directly on your home directory but a sub directory

But the files are owned by root for a reason. Are you trying to fix the wrong problem? Maybe your workflow does not really need rail sudo commands? Then again I presume gems have to be installed system wide, so perhaps...

Anyway what about running a nautilus window as root:

sudo nautilus /home/foo

Or use the files sidebar in GEdit for file navigation?

  • Running nautilus as sudo helped! Commented Mar 17, 2011 at 13:32

Please read following:


In general it depends on the situation how to handle owner/file permissions.


First, avoid the need to use sudo. Figure out what your script is accessing that you don't have access to, and change the permissions on that file so you have access without having to resort to sudo.

If you can't get around the need for sudo, then after running such a command, just sudo chown the files it creates back to yourself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .