Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm able to write changes in the home directory, but when it comes to the /var/www/html folder, it's not allowing me to make any changes or create new files or folders.

I'm able to view the files in the directory.

Please suggest what are the correct steps to set the permissions.

share|improve this question

Find the group that /var/www/html belongs to, usually one of apache, www, or webmaster. Then add your user to that group.

sudo usermod -a -G <groupname> <your_username>

where is the name of the group that /var/www/html belongs to and is the name of your user.

share|improve this answer
Unless the group is root. Then, don't do that. – mattdm Aug 9 '11 at 19:23
@mattdm That is a good point I hadn't thought of. However, I doubt that the owner of /var/www/html would be root unless he's made some configuration changes. However, I don't think that this would be the case. – Kevin M Aug 11 '11 at 4:05
Root is the default owner of that directory on all Fedora and RHEL systems, and all derivatives that I'm aware of. – mattdm Aug 11 '11 at 4:09
With my initial Digital Ocean Ubuntu /var/www/html/ was setup as root:root owned so group and owner changes are sometimes needed and user should not be added to group root as mattdm suggested. – rhand May 1 '15 at 11:14

My suggestion is to use /srv/. That's what it's there for. Create an appropriate hierarchy (perhaps /srv/www/, but maybe something more appropriate for your group). Then, change the Apache configuration so that the new directory is your DocumentRoot.

This has several advantages:

  • You are working in space that is by definition reserved for files for services like this, meant to be managed by the local organization or systems administrator. You can organize things in a way that makes sense to you.
  • You're not messing with files or directories that are owned by a package manager. (If you change the permissions of a file owned by a package, they might get "fixed" back when a security update comes along.)
  • You're not creating non-transient files in /var. This can help with your backup strategy.
share|improve this answer

as root :

chown -R user /var/www/html/

Replace "user" with your username.

share|improve this answer
This won't work unless you have privileges. If the user can't write to or change things in /var/www/html, he likely can't change permissions either. – gabe. Aug 8 '11 at 13:25
You are correct, I will edit my answer – Lucas Kauffman Aug 8 '11 at 13:27
most of the time the /var/www/html dir is owned by the web user ( www-data or http , ...). Adding your user to that group fixed the problem also. – Goez Aug 8 '11 at 13:37
"most of the time" is "on some distributions" – mattdm Aug 11 '11 at 21:10

Your Answer


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.