What chmod 666 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 | 6 |
rw- |
Can read and modify | Can list files (write has no effect without execute) |
| others | 6 |
rw- |
Can read and modify | Can list files (write has no effect without execute) |
Each digit is the sum of read (4), write (2) and execute (1). In
ls -l output it looks like this:
$ ls -l
-rw-rw-rw- 1 alice staff 1834 Oct 21 10:30 example.txt
- The owner can read and write.
- The group can read and write.
- Everyone else can read and write.
When to use 666
- Device files like /dev/null
- Rarely right for regular files
666 is the starting point for new files before the umask is applied, and the mode of /dev/null and /dev/tty. On a regular file it means any user can overwrite it. If several users need to write a file, give them a shared group and use 664 instead.
Is chmod 666 safe?
Rarely. Every user and process on the system can modify it. Give the users who need access a shared group instead.
Commands
# One file
chmod 666 file
# Same thing in symbolic form
chmod u=rw,g=rw,o=rw file
# Every file under a tree (leaves directories alone)
find /path/to/dir -type f -exec chmod 666 {} +
# Check the result
stat -c '%a %A %n' file # Linux
stat -f '%Lp %Sp %N' file # macOS
Avoid chmod -R 666 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 |
|---|---|---|
664 |
rw-rw-r-- |
Lets the owner and group read and write, and others only read |
660 |
rw-rw---- |
Lets the owner and group read and write, and others nothing |
Other chmod values
777 · 775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 664 · 660 · 644 · 640 · 600 · 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 666 mean?
chmod 666 sets the permissions to rw-rw-rw-. The owner can read and write. The group can read and write. Everyone else can read and write.
Is chmod 666 safe?
Rarely. Every user and process on the system can modify it. Give the users who need access a shared group instead.