chmod 644: what it means
chmod 644 gives the owner read and write, and everyone else read only. It is the usual mode of a regular file that people or the web server must read but only one account may change: pages, images, configuration files, documents. With the default umask of most systems, 022, a newly created file already starts as 644.
The calculator shows this mode as rw-r--r--, and ls -l prints a regular file as -rw-r--r-- and a directory as drw-r--r--. Open the page on that mode and toggle a box to see the number change.
Digit by digit
| Who | Digit | Bits | Can |
|---|---|---|---|
| Owner (u) | 6 | rw- | read, write |
| Group (g) | 4 | r-- | read |
| Others (o) | 4 | r-- | read |
Each digit adds read = 4, write = 2 and execute = 1. For this mode the command is chmod 644 path, and the umask that produces it on a directory is 133.
Where it is used
- Website files: HTML, CSS, JavaScript and images served by nginx or Apache.
- Configuration that every process may read but only root edits, such as files in /etc.
- Shared documents and public keys (the .pub file of an SSH key is 644).
Modes usually given to files
| Mode | Symbolic | What it is for |
|---|---|---|
| 400 | r-------- | Read-only even for the owner: secrets that must not be edited. |
| 600 | rw------- | Private: SSH private keys, .env files with passwords. |
| 640 | rw-r----- | Owner edits, the group reads: logs and configs shared with a service group. |
| 644 | rw-r--r-- | Owner edits, everyone reads: the normal file. |
| 664 | rw-rw-r-- | Owner and group edit: a shared project folder, with care. |
The umask that sets the starting mode
New files start from 666 and new directories from 777; the umask removes bits. Computed with the calculator:
| umask | New files | New directories |
|---|---|---|
| 022 | 644 | 755 |
| 002 | 664 | 775 |
| 027 | 640 | 750 |
| 077 | 600 | 700 |
Commands
Set the mode of one file, or of all files and folders separately
chmod 644 index.html
find /var/www/site -type f -exec chmod 644 {} +
find /var/www/site -type d -exec chmod 755 {} +See the result
ls -l index.html
stat -c "%a %A %U:%G %n" index.htmlCommon mistakes
- Running chmod -R 644 on a folder: directories lose the execute bit, which is what lets anyone enter them, and the whole tree becomes inaccessible. Use the find commands above.
- Leaving an SSH private key at 644: ssh refuses it with "UNPROTECTED PRIVATE KEY FILE". A private key must be 600.
- Using 644 for a script you want to run: without the x bit it cannot be executed directly; that needs 755.
Frequently asked questions
What does chmod 644 mean?
Three digits, for owner, group and others: 6 is read plus write (4+2), 4 is read only. So the owner can read and write, and group and others can only read: rw-r--r--.
Is 644 safe for a web server?
Yes for public files: the server reads them and nobody but the owner can change them. Files with secrets (passwords, keys) should be 600 or 640 instead.
What umask gives new files 644?
022: new files start from 666 and new folders from 777, and the umask removes its bits. The table above shows the result for the common umasks.