Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm new to Linux admin'ing. I created a user named webadmin and I want to give it permission to read/write in the /var/www/html directory.

How do I go about doing this?

share|improve this question
    
What distribution? –  SvW Sep 12 '11 at 1:16
    
serverfault.com/questions/184548/… –  quanta Sep 12 '11 at 2:16
add comment

1 Answer 1

up vote 7 down vote accepted

Personally, I would set the ownership of /var/www/html to apache. You can do this by:

chown apache /var/www/html

Next, I would create a group of let's say "Web admins":

groupadd webadmins

Add the user webadmin to the newly created group:

usermod -G webadmins webadmin

Add group permissions to the newly created group:

chmod g+rw /var/www/html 
share|improve this answer
    
and also you can create ACL. –  Luciano Facchinelli Sep 12 '11 at 0:54
    
On Debian-based distributions, this approach will fail as they run Apache as user/group www-data:www-data, not as apache by default. –  SvW Sep 12 '11 at 1:16
    
Thank you for that. –  Richardp Sep 12 '11 at 2:02
    
Note that files and directories created by a user will be owned by the user's primary group. In order to preserve these group permissions for users who don't have apache as their primary group, you should also set g+s on the directory (and any pre-existing subdirectories). This will ensure that any file created underneath, regardless of who creates it or what their memberships are, are owned by the same group that owns the directory they're created under. –  jgoldschrafe Sep 12 '11 at 2:06
    
I don't have permission to "comment" yet so I'll just expand on @Richardp's answer to save anyone from following blindly and then having to undo later (my own newbie mistake!). In case webadmin needs to be in multiple groups, don't forget the -a flag: usermod -a -G webadmins webadmin -- and regarding @jgoldschrafe's comment, in case you want to modify only directories, sudo find . -type d -exec chmod g+s {} \; –  Joe Corneli Mar 5 '13 at 15:22
add comment

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.