chmod 666 rw-rw-rw-

chmod 666 (rw-rw-rw-): the owner can read and write; group and others can read and write. Typical use: device files like /dev/null. Commands and umask.

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

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)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

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

Read and write for everyone. That is right for a few special device files: /dev/null, /dev/zero and /dev/tty are 666. On a regular file it lets every user and process on the machine change the contents.

Security notes

  • Others can write: every user and every process on the machine, including a compromised web application, can change or replace this. For a directory, they can delete or swap any file inside it.

Commands

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

The umask that gives 666

  • umask 000: new files are created as 666 (and directories as 777)

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 777 (rwxrwxrwx).

Other common modes

Work out any other mode in the chmod calculator