chmod 600
Only the owner can read and write, and nobody else has any access. The mode for SSH private keys and files with passwords in them.
| Read (4) | Write (2) | Execute (1) | Digit | |
|---|---|---|---|---|
| Owner | 6 | |||
| Group | 0 | |||
| Others | 0 |
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 and others have no access.
chmod 600 filechmod u=rw,g=,o= fileCommon values
What 600 allows
| Who | Digit | On a file | On a directory |
|---|---|---|---|
| Owner | 6 rw- | read and change | see the names, nothing more |
| Group | 0 --- | nothing | nothing |
| Others | 0 --- | nothing | nothing |
ls -l shows this mode as -rw------- on a file and as drw------- on a directory.
Only the owner can read the file and change it. To every other account it is closed. Root is the exception, as always: it is not held back by permissions.
Where it belongs
- SSH private keys.
sshchecks the mode before it uses a key. If the group or others can read the file, it prints "UNPROTECTED PRIVATE KEY FILE", says the permissions are too open and ignores the key.chmod 600 ~/.ssh/id_ed25519solves that. - Files with passwords in them, such as
.pgpass,.netrcor an.envfile. PostgreSQL refuses to use a.pgpassthat others can read.
600 or 400
400 also takes away the owner's own write permission, which protects against overwriting the file by accident. ssh accepts both. Since you own the file, you can give yourself write permission back whenever you need it.
Not for directories
A directory with 600 can't be entered, not even by its owner. The private mode for a directory is 700.
The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.