What are octal and symbolic chmod modes?

chmod sets the permissions of a file on Linux, macOS, and other Unix systems, and it accepts them in two notations. An octal mode such as 755 has one digit each for the owner, the group, and everyone else, where read is 4, write is 2, and execute is 1. A symbolic mode such as u=rwx,g=rx,o=rx names the classes (u owner, g group, o others, a all) and the permissions (r, w, x) instead.

Symbolic modes can also change permissions instead of setting them all: u+x adds execute for the owner, go-w removes write for group and others, and g=u copies the owner's permissions to the group. An octal mode always sets every permission, so the octal result of a change depends on the mode the file had before.

Tool description

This tool converts chmod modes between octal and symbolic notation. Pick the source and target notation, or leave the source on auto-detect: enter 755 to get u=rwx,g=rx,o=rx, or enter a symbolic mode to get the octal value. For changes like u+x or a+X, enter the file's current mode and see the mode chmod would leave it with. You can also paste a permission string from ls -l, such as -rwxr-xr-x, or a whole chmod command.

Examples

Octal Symbolic ls -l Typical use
644 u=rw,go=r -rw-r--r-- Regular files
755 u=rwx,go=rx -rwxr-xr-x Scripts, programs, and directories
600 u=rw,go= -rw------- Private files such as SSH keys
2775 u=rwx,g=rwxs,o=rx drwxrwsr-x Shared directories that keep their group
1777 a=rwx,+t drwxrwxrwt /tmp and other shared scratch folders
4755 u=rwxs,go=rx -rwsr-xr-x Programs such as passwd

Features

  • Converts octal to symbolic and symbolic to octal, with a swap button to switch direction
  • Detects the notation of the mode you enter, or converts from the notation you pick
  • Applies relative changes such as u+x, go-w, a=r,u+w, g=u, and a+X to a current mode
  • Handles setuid, setgid, and the sticky bit (s, t, and 4-digit octal modes)
  • Writes the symbolic mode in full (u=rwx,g=rx,o=rx) or compact (u=rwx,go=rx)
  • Reads and writes ls -l permission strings, including s, S, t, and T
  • Accepts pasted commands such as sudo chmod -R 755 dir
  • Points to the exact character when a mode is invalid

How it works

An octal mode is read as up to four digits: the optional first digit holds setuid (4), setgid (2), and sticky (1), and the other three hold the owner, group, and others permissions. A symbolic mode is read clause by clause, following the POSIX grammar, and applied to the current mode the way GNU chmod on Linux does:

  • + adds permissions, - removes them, and = sets them and clears the rest for the classes named.
  • X adds execute only to directories and to files that already have execute for someone.
  • s sets setuid with u and setgid with g. t sets the sticky bit with o, a, or no class.
  • Without a class, as in +x, the change applies to everyone except the bits blocked by the umask.
  • On directories, setuid and setgid stay as they are unless the mode names them, as in g-s.

The symbolic output sets every bit explicitly, so on a file it gives the same result whatever mode the file had before. The sticky bit is written as a separate +t clause because GNU and BSD chmod both accept it in that form.

Tips

  • Use a+X with chmod -R to make directories searchable without making every file executable.
  • chmod 755 on a directory doesn't clear setgid with GNU chmod. Use chmod 00755 or g-s to remove it.
  • Ansible and many config files expect a leading zero, as in 0755. Turn on "Always show 4 octal digits" to get it.
  • A . or + after an ls -l string marks an SELinux context or an ACL. Use getfacl to see ACL entries, which the mode doesn't show.