Apply for Free VPS

File permissions and ownership

Updated 27 Nov 2026 security permissions

Read permission strings and fix the common access errors.

ls -l /var/www

In -rw-r-----, the first character is the type, then three sets of read, write and execute for the owner, the group and everyone else.

Number Meaning Typical use
600 Owner reads and writes Private keys, secret files
640 Owner writes, group reads Application configuration
644 Everyone reads Public web files
700 Owner only, directory ~/.ssh
755 Everyone enters and reads Public directories

Change them

sudo chown -R deploy:www-data /var/www/site
sudo find /var/www/site -type d -exec chmod 750 {} +
sudo find /var/www/site -type f -exec chmod 640 {} +

Directories need execute

Without x on a directory you cannot enter it. Check every level of a path:

namei -l /var/www/site/index.html

Never use 777

It lets any process on the server change the files, so one weak application can take over another. Give the right user or group access instead.

Writable folders

Let the application write only where it must, such as upload and cache folders.

Was this helpful?

Report outdated or incorrect information