Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 am trying to set permissions with

sudo 775 - R  /var/www/

on all folders and all files in the www folder of lamp for sudo user.

Is this the correct way to set up the system?

share|improve this question
up vote 5 down vote accepted

The proper permission under /var/www/ is 755 for folders and 644 for files.

  • The value for 755 is readable by User, Group, and World, writable by User, executable by User, Group, and World. For uploading folder it should be different, and you should change manually.

  • Whereas the value for 644 is readable by User, Group, and World, but writable only by User.

The short command to set folder and file under /var/www/ to 755 and 644 is:

find /var/www -type d -exec chmod 755 {} \; 

find /var/www -type f -exec chmod 644 {} \;

These are simple commands so you will get all folder and files into these permissions, of course, that is not the best practice, it would better if you set spesifically the folders or files that you want to set (I edit this answers after considering comments from AzkerM).

share|improve this answer
Assigning 644 to the whole root in /var/www directory is not a good practice though. Instead OP can try assigning permissions to the necessary directories as needed. – AzkerM May 14 '14 at 7:43
It would be better if you describe in a structured, so everyone will know how best we should do :) That includes me will learn from it. – metamorph May 15 '14 at 10:30
There is nothing wrong in your answer but it is always better to add a precaution advising the OP about the permissions. After all, the whole www directory will face the public. A simple permission issue can cause lots of problems. Keep up your good work. :) – AzkerM May 15 '14 at 11:07
Thank you AzkerM for your suggestion, I have edited my answers, thank you again :) – metamorph May 15 '14 at 11:19

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.