chmod 644

chmod 644 is rw-r--r--: when to use it, find commands for whole trees, the umask behind it and the usual mistakes.

loading chmod 644
About this tool

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

WhoDigitBitsCan
Owner (u)6rw-read, write
Group (g)4r--read
Others (o)4r--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

ModeSymbolicWhat it is for
400r--------Read-only even for the owner: secrets that must not be edited.
600rw-------Private: SSH private keys, .env files with passwords.
640rw-r-----Owner edits, the group reads: logs and configs shared with a service group.
644rw-r--r--Owner edits, everyone reads: the normal file.
664rw-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:

umaskNew filesNew directories
022644755
002664775
027640750
077600700

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.html

Common 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.

Report a problem