Ubuntu – Correct permissions for sudo LAMP /var/www directory

directorypermissionssudo

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?

• 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).