What chmod 600 means
| Who | Digit | Letters | On a file | On a directory |
|---|---|---|---|---|
| owner | 6 |
rw- |
Can read and modify | Can list files (write has no effect without execute) |
| group | 0 |
--- |
No access | No access |
| others | 0 |
--- |
No access | No access |
Each digit is the sum of read (4), write (2) and execute (1). In
ls -l output it looks like this:
$ ls -l
-rw------- 1 alice staff 1834 Oct 21 10:30 example.txt
- The owner can read and write.
- The group can do nothing.
- Everyone else can do nothing.
When to use 600
- SSH private keys
- .env files and credentials
- ~/.netrc, ~/.pgpass, kubeconfig
OpenSSH, PostgreSQL’s ~/.pgpass and many other tools refuse to use a credentials file that others can read, with errors like “UNPROTECTED PRIVATE KEY FILE”. 600 fixes them. Use it for .env files on servers, too.
600 is also the default mode for new files, with umask 077.
Is chmod 600 safe?
Yes. Nobody outside the owner can access it at all (except root).
Commands
# One file
chmod 600 file
# Same thing in symbolic form
chmod u=rw,g=,o= file
# Every file under a tree (leaves directories alone)
find /path/to/dir -type f -exec chmod 600 {} +
# Check the result
stat -c '%a %A %n' file # Linux
stat -f '%Lp %Sp %N' file # macOS
Avoid chmod -R 600 on a whole tree: it gives files and directories the same mode. The
find form above changes only files.
Compare with similar modes
| Mode | Symbolic | Difference |
|---|---|---|
700 |
rwx------ |
Gives the owner full access and everyone else nothing |
660 |
rw-rw---- |
Lets the owner and group read and write, and others nothing |
640 |
rw-r----- |
Lets the owner read and write, the group read, and others nothing |
500 |
r-x------ |
Lets only the owner read and execute |
400 |
r-------- |
Lets only the owner read |
000 |
--------- |
Gives nobody any access |
Other chmod values
777 · 775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 666 · 664 · 660 · 644 · 640 · 555 · 500 · 444 · 400 · 000 · 1777 · 2775 · 4755
Need a different combination? Use the Chmod Calculator.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What does chmod 600 mean?
chmod 600 sets the permissions to rw-------. The owner can read and write. The group can do nothing. Everyone else can do nothing.
Is chmod 600 safe?
Yes. Nobody outside the owner can access it at all (except root).