chmod 664 rw-rw-r--

chmod 664 (rw-rw-r--): the owner can read and write, the group read and write, others read. Typical use: team files under umask 002. Commands and umask.

Octal
664 (also written 0664)
Symbolic
rw-rw-r--
ls -l shows
-rw-rw-r-- for a file, drw-rw-r-- for a directory
chmod letters
u=rw,g=rw,o=r

Who can do what

ClassDigitBitsOn a fileOn a directory
Owner (u)6rw-Read the contents and change or empty the contentsList the names inside, nothing more with write alone (it needs execute to work) and see names only, not open or inspect the files
Group (g)6rw-Read the contents and change or empty the contentsList the names inside, nothing more with write alone (it needs execute to work) and see names only, not open or inspect the files
Others (o)4r--Read the contentsList the names inside and see names only, not open or inspect the files

Each digit adds read (4), write (2) and execute (1). Deleting or renaming a file depends on write and execute on the directory that holds it, not on the file's own mode. Root bypasses read and write checks.

Typical uses

The owner and the group read and write, others read. New files get it under umask 002, which systems with a private group per user usually give ordinary users. It suits files a team edits together in a shared project.

Security notes

  • The group can write, so check who is in the group; adding a user to it gives them write access.
  • Every account on the machine can read it, so keep passwords, keys and tokens out of anything with this mode.

Commands

  • Numeric
    chmod 664 file
  • Symbolic
    chmod u=rw,g=rw,o=r file
  • Check the result
    stat -c '%a %A %n' file
  • Files only, recursively
    find /path -type f -exec chmod 664 {} +

The umask that gives 664

  • umask 002: new files are created as 664 (and directories as 775)

Programs create files with 666 and directories with 777, and the umask removes bits from those. A umask never adds execute to a new file, and it cannot set setuid, setgid or the sticky bit.

Its directory counterpart is chmod 775 (rwxrwxr-x).

Other common modes

Work out any other mode in the chmod calculator