chmod 644 rw-r--r--

chmod 644 (rw-r--r--): the owner can read and write; group and others can read. Typical use: web files and normal documents. Commands and umask.

Octal
644 (also written 0644)
Symbolic
rw-r--r--
ls -l shows
-rw-r--r-- for a file, drw-r--r-- for a directory
chmod letters
u=rw,g=r,o=r

Who can do what

ClassDigitBitsOn a fileOn a directory
Owner (u)6rw-Read the contents and change or empty the contentsList the names inside, nothing more with write alone (it needs execute to work) and see names only, not open or inspect the files
Group (g)4r--Read the contentsList the names inside and see names only, not open or inspect the files
Others (o)4r--Read the contentsList the names inside and see names only, not open or inspect the files

Each digit adds read (4), write (2) and execute (1). Deleting or renaming a file depends on write and execute on the directory that holds it, not on the file's own mode. Root bypasses read and write checks.

Typical uses

The owner reads and writes, everyone else can read. It is what new files get under the common umask 022, and the usual mode for web pages, images, stylesheets and most of /etc (/etc/passwd is 644). WordPress recommends 644 for files. On a shared server, files holding passwords should be 640 or 600 instead.

Security notes

  • Only the owner (and root) can change it; the group and others are limited to the read and execute rights shown above, which is the usual safe pattern for shared files and directories.
  • Every account on the machine can read it, so keep passwords, keys and tokens out of anything with this mode.

Commands

  • Numeric
    chmod 644 file
  • Symbolic
    chmod u=rw,g=r,o=r file
  • Check the result
    stat -c '%a %A %n' file
  • Files only, recursively
    find /path -type f -exec chmod 644 {} +

The umask that gives 644

  • umask 022: new files are created as 644 (and directories as 755)

Programs create files with 666 and directories with 777, and the umask removes bits from those. A umask never adds execute to a new file, and it cannot set setuid, setgid or the sticky bit.

Its directory counterpart is chmod 755 (rwxr-xr-x).

Other common modes

Work out any other mode in the chmod calculator