Linux file permissions
chmod 664: what it means and when to use it
chmod 664 lets the owner and the group read and write the file, while everyone else can only read it.
664
rw-rw-r--
| Who | Digit | Read | Write | Execute |
|---|---|---|---|---|
| Owner | 6 |
Yes | Yes | No |
| Group | 6 |
Yes | Yes | No |
| Everyone else | 4 |
Yes | No | No |
How chmod 664 works
The two 6s give read and write to the owner and the group. The final 4 is read only for everyone else, and nobody can execute the file.
664 is the file partner of 775. In a shared project, files are 664 and directories are 775, so everyone in the group can edit and create files while people outside it can still read them.
Where 664 belongs
- Files in a shared team directory
- Content edited by both a deploy user and a web server group
- Log files written by several services in one group
The command
Both of these set exactly the same permissions. The number is shorter; the letters are easier to read back later.
chmod 664 filename
chmod u=rw,g=rw,o=r filename
Like 644, it is not suitable for files that hold secrets, since everyone on the machine can read them.