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?


1 Answer 1


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 
  • 1
    and also you can create ACL. Sep 12, 2011 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.
    – Sven
    Sep 12, 2011 at 1:16
  • 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. Sep 12, 2011 at 2:06
  • 1
    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 {} \; Mar 5, 2013 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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