breakitdown

chmod 600 (rw-------)

Answer

chmod 600 sets rw-------: the owner can read and write the file, and no one else (other than root) can open it at all. It is the standard mode for files that contain secrets.

Try

chmod 600 = rw-------: owner read and write, everyone else nothing.

Read 4Write 2Execute 1Digit
Owner (user)6
Group0
Others0
Special0
  1. 6
    Owner (user): 6 = 4 read + 2 write
  2. 0
    Group: 0 = no permissions
  3. 0
    Others: 0 = no permissions

On a file

  • Owner (user) read it and change it
  • Group no access
  • Others no access

On a directory

  • Owner (user) list the names inside; write without x does nothing useful (names only: without x the files cannot be opened or even stat'ed)
  • Group no access
  • Others no access

chmod 600 filechmod u=rw,go= filels -l → -rw-------

What to know

6 for the owner is read + write; the two zeros remove every permission for the group and for others. Several programs check for exactly this and refuse to use a secrets file that is more open.

OpenSSH rejects a private key if any group or other bit is set, so 600 and 400 both work, while 640 and 644 do not. PostgreSQL's client ignores a ~/.pgpass file that is group- or world-accessible, and prints a warning asking for 0600.

Where it fits

Gotchas

Related explainers

← chmod calculator