This question already has an answer here:

After looking around this site, it's been said that it's best practice to use 644 permission for my websites in /var/www.

So I have done chmod 644 /var/www/mysite

I now no longer have access to the mysite folder, permission denied. After asking this question it seems that I need to allow my user execute permissions.

I've done this but now feel I am in a bit of a mess.

So could someone please explain the best practice when it comes to setting permissions for /var/www/mysite?

I want myuser to be able to go in there. What sort of access should www-data have? Basically what permissions should I set for this folder and sub folders for each user?

marked as duplicate by zwets, Zanna, muru, Pilot6, David Foerster Oct 27 '16 at 10:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


use 644 permission for my websites in /var/www.

NO. Nobody said this.

  • "use "600" up "644" permission for my websites in /var/www" FOR FILES.
  • You use "700" up to "755" for directories (what you want depends on your usecase).

These 2 commands fix your permissions:

find /var/www/ -type d -print0 | xargs -0 chmod 755 
find /var/www/ -type f -print0 | xargs -0 chmod 644

The first sets directories to 755. The seconds sets files to 644.

Permissions come in 3 groups: owner, group and others. If you edit files only with 1 user you could also use "700" and "600". That will disallow the group and others to access the files. "750" and "650" allows also access for the group.

  • Thanks, it is safe to allow everyone to execute the folders? Also what does -print0 mean in your example? – panthro Oct 27 '16 at 10:49
  • depends on your usecase. if you want people to upload a file it might be needed. I myself tend to use "750" so others can do nothing. Regarding print0: if xargs is run with a -0 option, it'll expect NULL-separated strings as output by find ... -print0 so it will execute the command 1 time with more names instead of each time find feeds it something . – Rinzwind Oct 27 '16 at 11:39

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