chmod 664
chmod 664 sets rw-rw-r--: the owner and members of the file's group can read and modify it, and everyone else can read it. No one can execute it.
Permission matrix
| Who | Read (4) | Write (2) | Execute (1) | Digit |
|---|---|---|---|---|
| Owner (u) | Yes | Yes | No | 6 |
| Group (g) | Yes | Yes | No | 6 |
| Others (o) | Yes | No | No | 4 |
Execute means different things by type. On a file it lets the kernel run it as a program. On a directory it is search permission: entering it (cd) and reaching the files inside by name. Read on a directory only lists names.
| Who | On a file | On a directory |
|---|---|---|
| Owner (u) | Read and modify | List names only; write does nothing without execute |
| Group (g) | Read and modify | List names only; write does nothing without execute |
| Others (o) | Read the contents | List names only; cannot enter or open entries |
Facts
| Octal | 664 (0664) |
|---|---|
| Symbolic | rw-rw-r-- |
| ls -l, file | -rw-rw-r-- |
| ls -l, directory | drw-rw-r-- |
| Equivalent symbolic command | chmod ug=rw,o=r |
| Default umask that creates it | umask 002 for new files |
| How Git records a file with it | 100644 (not executable) |
| Special bits | None |
When to use it
- Files in shared project trees where several accounts in one group edit the same files; pair with 2775 directories so the group stays consistent.
- Content the web server must rewrite when it shares a group with your user (the 664 case in the WordPress permissions guide).
- It is what new files get under umask 002, the default for regular users on systems with user private groups.
When not to use it
- When the group is shared with accounts you do not fully trust: they can rewrite the file.
- Secrets: others can still read it. Use 640 or 600.
- SSH files: authorized_keys that is group-writable makes sshd reject key logins under StrictModes.
Commands
chmod 664 README.md
chmod ug=rw,o=r README.md # same resultstat -c '%a %A %n' README.md # Linux (GNU stat): 664 -rw-rw-r--
stat -f '%Lp %Sp %N' README.md # macOS and BSDApplying it to a whole tree
chmod -R would put the same mode on files and directories alike. Set directories to 775 and files to 664 separately:
find . -type d -exec chmod 775 {} +
find . -type f -exec chmod 664 {} +Or in one pass with a capital X, which adds execute only to directories and to files that already had it: chmod -R ug=rwX,o=rX ..
Git and the execute bit
Git stores only one permission fact per file: 100755 if the owner execute bit is set, 100644 otherwise. A file with this mode is committed as 100644; the group and others bits never reach the repository. On Windows, or where core.fileMode is false, set the bit with git update-index --chmod=+x.
Frequently asked questions
- What does chmod 664 mean?
- Owner 6 (rw-), group 6 (rw-), others 4 (r--). Owner and group can edit, others can read.
- Why are my new files 664 instead of 644?
- Your umask is 002 rather than 022. Many distributions set 002 for regular users because each user has a private group with the same name, so group write only reaches you.
- What is the difference between 664 and 644?
- The group digit: 6 lets group members modify the file, 4 only lets them read it.
Last reviewed by Arielton Oberek.