Owner can read and write. Group can read and write. Others can read.
| Read | Write | Execute | |
|---|---|---|---|
| Owner | ✓ | ✓ | – |
| Group | ✓ | ✓ | – |
| Others | ✓ | – | – |
Typical use
Files a group edits together.
Good to know
664 (rw-rw-r--) lets the owner and group edit a file, while everyone else can read it. It suits shared documents and source files edited by a team, or files written by both a deploy user and a web server in the same group. It is the default for new files under umask 002, which many distributions use when every user has a private group of their own.
For group write to work, the file must belong to the right group (chgrp, or setgid on the parent folder) and the folder needs 775 so members can create and rename files. Git only records the executable bit, not 664 versus 644, so set core.sharedRepository=group on repositories shared through the file system. Don’t use 664 for secrets: others can still read them.
Commands
| Set the mode | chmod 664 file |
|---|---|
| The same with letters | chmod u=rw,g=rw,o=r file |
| A folder and everything in it | chmod -R 664 folder |
| Only the folders inside | find folder -type d -exec chmod 664 {} + |
| How ls -l shows it | -rw-rw-r-- |