Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question

3 Answers 3

up vote 2 down vote accepted

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?

http://bashscript.blogspot.com/2010/03/unixlinux-advanced-file-permissions.html

http://bashscript.blogspot.com/2010/03/creating-user-group-and-shared.html

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?

share|improve this answer
    
Running nautilus as sudo helped! –  Ciaran Archer Mar 17 '11 at 13:32

Please read following:

https://help.ubuntu.com/community/FilePermissions

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

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.