What chmod 664 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 | 4 |
r-- |
Can read | Can list files |
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-r-- 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.
When to use 664
- Files edited by a team
- Default for new files with umask 002
664 is 644 with write access for the group. Systems that give each user a private group, like Fedora and Ubuntu, often default to umask 002, which creates new files as 664. In a shared directory with setgid (2775), it lets everyone in the group edit each other’s files.
664 is also the default mode for new files, with umask 002.
Is chmod 664 safe?
Yes, for files edited by a team. Other users can read it, but can’t change it. Don’t use it for files that contain secrets.
Commands
# One file
chmod 664 file
# Same thing in symbolic form
chmod u=rw,g=rw,o=r file
# Every file under a tree (leaves directories alone)
find /path/to/dir -type f -exec chmod 664 {} +
# Check the result
stat -c '%a %A %n' file # Linux
stat -f '%Lp %Sp %N' file # macOS
Avoid chmod -R 664 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 |
|---|---|---|
666 |
rw-rw-rw- |
Lets everyone read and write, with no execute permission |
660 |
rw-rw---- |
Lets the owner and group read and write, and others nothing |
644 |
rw-r--r-- |
Lets the owner read and write, and everyone else only read |
Other chmod values
777 · 775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 666 · 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 664 mean?
chmod 664 sets the permissions to rw-rw-r--. The owner can read and write. The group can read and write. Everyone else can read.
Is chmod 664 safe?
Yes, for files edited by a team. Other users can read it, but can’t change it. Don’t use it for files that contain secrets.