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 am a web developer and have Apache setup on my local system for testing.

I keep running into issues with the permissions e.g. unless I chmod any new directories to 777 my IDE cannot write to the files there.

I was hoping there was a way to add myself to the group that has control of the www folder (and any sub folders) so I do not have to chmod the files every time.

share|improve this question

4 Answers 4

up vote 3 down vote accepted

I am working on a related issue, but in your case, you could just add yourself to the web group

sudo adduser USER$ www-data

replace USER$ with your username of course. www-data is the group used for apache web access.

share|improve this answer
    
not sure what I'm doing wrong, but this didn't work for me :( ubuntu@domU-12-31-39-16-26-01:/var/www$ sudo useradd ubuntu www-data Usage: useradd [options] LOGIN –  SSH This Apr 11 '13 at 18:52
    
@Alan: useradd and adduser are different commands and commonly confused. You can add your user to the group www-data with: sudo adduser $USER www-data As $USER is part of the env. vars - no need for replacement. –  gabriel_agm Apr 16 '13 at 15:15

don't use 777 just because it "works". You can use easier notation such as u+rwx in order to give the user the right permission. g for group, u for "user" and o for "others". chmod ugo+rwx is then equal to 777; anyone can do anything with any files or directory. Usually not what you want.

You may want to use setgid on the directory using chmod g+s. This way, when someone changes a file, the group ownership will stay the same. Also, when you create new files and directories, this will be inherited.

share|improve this answer
    
Thanks for the info, but if I'm the only one with ssh access to the box, can it still be a problem? –  SSH This Apr 11 '13 at 18:51
    
Yes, never neglect security. Give yourself the correct permissions, but not any other user. Remember; humans aren't the only users on your system. If one service gets compromised, it should not have the ability to compromise another. –  Jo-Erlend Schinstad Apr 12 '13 at 15:16

If you use an desktop environment, you can do this.
Open the terminal and enter:

gksudo nautilus

Enter your password and hit Enter. Navigate to the www folder and right-click. Choose properties and afterwards permission. Now you can change the access.
To quit Nautilus, just close it and to close the terminal, idem.

share|improve this answer
    
where we have nautilus in a VPS server? –  Pavak Paul Apr 22 at 5:08

You could do this, if you just want to add your user:

sudo chgrp -R yourusername /var/www
sudo find /var/www -type d -exec chmod g=rwxs {} \;
sudo find /var/www -type f -exec chmod g=rws {} \; 

Replace yourusername with the actual user name that you want to add. One last thing, you can keep adding user names by repeating the command, only putting their user name.

Hope this helps!

Source

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.