DEVESSENTIALS

chmod 664 — what does it mean?

664 is the file counterpart of 775: group members can edit the file, everybody else can read it. It is what new files get with umask 002, the default for regular users on many Linux distributions that give each user a private group of the same name. Because your private group contains only you, 664 there behaves like 644; the extra group write matters only when the file's group is a real shared group.

In plain English

664

rw-rw-r--

The owner and members of the file's group can read and write; all other users can only read. Nobody can execute it.

Symbolic equivalent: chmod u=rw,g=rw,o=r notes.md

Open 664 in the chmod calculator

What each digit in 664 means

Each octal digit is the sum of read (4), write (2) and execute (1) for one class of users. The digits are, in order, the file's owner, the file's group, and everyone else.

ClassDigitSumr w xls -l
Owner (u)64 + 2 + 0rw-rw-
Group (g)64 + 2 + 0rw-rw-
Others (o)44 + 0 + 0r--r--
  • Owner: can read the contents and modify the contents; no execute.
  • Group: can read the contents and modify the contents; no execute.
  • Others: can read the contents; no write or execute.

When to use chmod 664

  • Files in a shared team directory (2775) that any member may edit: docs, shared configs, data files.
  • Web content edited by a deploy group and served read-only to everyone, e.g. owner alice, group www-data.
  • Log files a group of services appends to, when you want them readable by monitoring tools.

Security risks and gotchas

Group write is real write

Any group member can overwrite or truncate a 664 file. If the group is broad, such as users, staff or www-data shared by several apps, a compromise of one member is write access to the file. Check with ls -l which group actually owns it.

Still world-readable

The final 4 means any local user can read the file. Do not use 664 for files that contain credentials; use 660 or 640 instead.

A world-writable directory undoes it

The file's mode only controls editing its contents. Who can delete or replace the file is decided by the directory's write bit, so a 664 file inside a 777 directory can be swapped by anyone.

Commands

Set 664 on a file

chmod 664 notes.md

Equivalent to chmod ug=rw,o=r notes.md.

Add group write to an existing 644 file

chmod g+w notes.md

Leaves all other bits alone.

All files in a shared tree

find /srv/shared -type f -exec chmod 664 {} +

Do not use chmod -R 664: directories need execute and would become unenterable.

Make new files 664 by default

umask 002

Put it in ~/.profile or the service's systemd unit (UMask=0002). New files become 664, new directories 775.

How to check for 664

# Symbolic view
ls -l notes.md
-rw-rw-r--  1 alice devs  1820 Oct 16 09:12 notes.md

# Octal view (Linux / GNU coreutils)
stat -c '%a %A %n' notes.md
664 -rw-rw-r-- notes.md

# Octal view (macOS / BSD)
stat -f '%Lp %Sp %N' notes.md

The first character of the ls -l output is the file type (- regular file, d directory), followed by the nine permission characters. stat -c %a prints the octal mode directly; it only shows a fourth leading digit when setuid, setgid or the sticky bit is set.

Related chmod modes

Try variations of 664 in the chmod calculator, browse all chmod modes, or read Linux file permissions explained for chown, umask and ACLs.

Frequently Asked Questions

What is the difference between 664 and 644?▾

664 adds write for the file's group. With 644 only the owner can modify the file; with 664 every member of its group can too. Others can read in both cases.

Why are my new files created as 664?▾

Your umask is 002. Programs create files with 666 and the umask removes write for others only, leaving 664. Many distributions use umask 002 for users who have a private group with the same name as the user.

Should web files be 664?▾

Only if a deploy group needs to edit them in place. If the web server's group owns them, 664 lets the web server modify your code, which you usually do not want. 644 is the safer default.