Every file and directory in Linux has three types of permissions: read (r), write (w), and execute (x). These are assigned to three categories: owner (u), group (g), and others (o).
| Value | Permission | Symbol |
|---|---|---|
| 7 | Read + Write + Execute | rwx |
| 6 | Read + Write | rw- |
| 5 | Read + Execute | r-x |
| 4 | Read Only | r-- |
| 3 | Write + Execute | -wx |
| 2 | Write Only | -w- |
| 1 | Execute Only | --x |
| 0 | No Permissions | --- |
chmod 755 script.sh # rwxr-xr-x
chmod 644 index.html # rw-r--r--
chmod 700 private.key # rwx------
chmod +x script.sh # Add execute for all
chmod -R 755 /var/www/ # Recursive on directory
Change which user and group owns a file.
sudo chown tom:www-data file.txt sudo chown -R www-data:www-data /var/www/html
What does chmod 644 do?