chmod 640 rw-r-----

chmod 640 (rw-r-----): the owner can read and write, the group read, others do nothing. Typical use: config files and logs read by a group.

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

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)0---NothingNothing

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, the group reads, everyone else gets nothing. Common for config files and logs read through a group: on Debian and Ubuntu /etc/shadow is 640 root:shadow, and many logs in /var/log are readable by the adm group. WordPress suggests 640 or 644 for files.

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.

Commands

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

The umask that gives 640

  • umask 027: new files are created as 640 (and directories as 750)
  • umask 037: new files are created as 640 (and directories as 740)

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 750 (rwxr-x---).

Other common modes

Work out any other mode in the chmod calculator