Skip to the content

chmod 640

The owner can read and write, the group can only read, and others have no access. For log files and configuration with something to hide.

Read (4)Write (2)Execute (1)Digit
Owner6
Group4
Others0

A program runs with the rights of the file's owner.

A program runs with the file's group. In a directory, new files get the directory's group.

In a directory, users can't delete or rename each other's files.

Owner can read and write. Group can read. Others have no access.

chmod 640 file
chmod u=rw,g=r,o= file

Common values

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What 640 allows

WhoDigitOn a fileOn a directory
Owner6 rw-read and changesee the names, nothing more
Group4 r--readsee the names, nothing more
Others0 ---nothingnothing

ls -l shows this mode as -rw-r----- on a file and as drw-r----- on a directory.

The owner can edit the file, members of the group can read it, and others get nothing.

Where it belongs

Files that one account writes and a few others have to read:

  • Log files. On Debian and Ubuntu /var/log/syslog is 640 with the group adm, so that administrators in that group can read the logs and ordinary users can't.
  • Configuration with passwords in it. Owned by root, with the group of the service that needs it: root can edit the file, the service can read it and nobody else can.
  • /etc/shadow, the file with the password hashes, is 640 on Debian-based systems, with a group of its own.

Next to 644 and 600

644 lets everyone read, 600 nobody but the owner. 640 sits between them, and it is only as good as the choice of group. Check with ls -l which group the file has, and who is in it.

For a directory the matching mode is 750.

The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.

See all 12