# File permissions: chmod and chown

> How Linux read, write and execute permissions work, what 755 and 644 mean, and how to change owner and mode safely.

Every file and directory on Linux has an owner, a group and three sets of permissions: for the owner, for the group and for everyone else. chmod changes the permissions (the mode), and chown changes the owner and group. 'ls -l' shows both.

## Reading permissions

In 'ls -l' output, '-rw-r--r--' means a regular file that the owner can read and write and others can only read. r is read, w is write and x is execute; for a directory, x allows entering it.

## Numeric modes

Each set is a digit: read is 4, write 2 and execute 1, added together. 644 (rw-r--r--) is typical for files, 755 (rwxr-xr-x) for directories and programs, and 600 (rw-------) for private files such as SSH keys.

## Changing the owner

'sudo chown user:group file' sets the owner and group. With '-R' both chmod and chown work recursively through a directory tree.

## How to fix permissions of a web folder

1. Check the current state: ls -l /var/www/site
2. Set the owner: sudo chown -R www-data:www-data /var/www/site
3. Set directories to 755: sudo find /var/www/site -type d -exec chmod 755 {} +
4. Set files to 644: sudo find /var/www/site -type f -exec chmod 644 {} +

## Cautions

- Never use 'chmod -R 777': it lets every user and process change the files.
- A recursive chmod or chown on the wrong path, such as / or /usr, can break the system.

## Sources

1. [chmod(1) manual page](https://man7.org/linux/man-pages/man1/chmod.1.html)
2. [chown(1) manual page](https://man7.org/linux/man-pages/man1/chown.1.html)

Last reviewed: 2026-10-08
URL: https://wiki.raincleaner.eu/linux/chmod-chown
