chmod Calculator

Convert Unix permissions between octal and symbolic notation, special bits included.

755 rwxr-xr-x

WhoReadWriteExecute
Owner
Group
Others
Special bits
Command
chmod 755 file

Runs in your browser. Nothing you enter is sent anywhere.

How to use it

Type a mode into Mode, octal or symbolic. It converts as you type, in your browser; nothing is uploaded. It reads an octal mode of up to 4 digits (644, 4755), the 9-character symbolic form (rwxr-xr-x), or the 10-character ls -l column (drwxr-xr-x), a trailing +, . or @ included.

  1. The answer line shows the octal and symbolic forms. A note under it explains a trailing + or a short mode like 7.
  2. In the table, tick or untick Read, Write and Execute for Owner, Group and Others. Under Special bits, tick setuid, setgid or Sticky. Any box you change rewrites the mode field in octal.
  3. Command shows chmod 755 file. Copy copies chmod 755 with a trailing space, ready for the filename.

If the text isn’t a mode, a message appears under the field and the last valid result stays on screen.

Examples

The mode column of a regular file, from ls -l:

-rw-r--r--

The answer reads 644 rw-r--r-- and Command shows chmod 644 file. The leading - is the file type, which chmod can’t change, so it’s dropped.

A shared project directory with an access control list, from ls -ld:

drwxrwsr-x+

The answer reads 2775 rwxrwsr-x, with setgid ticked. The lowercase s in the group’s execute slot means setgid and group execute are both on. The note explains the +: the directory has an ACL.

Setuid on a file nobody can execute:

4644

The answer reads 4644 rwSr--r--. The capital S is how ls marks a special bit without execute under it, which is usually a mistake.

chmod’s relative syntax:

u+x

The error is Use an octal mode like 755 or 4755, or a symbolic one like rwxr-xr-x. A relative mode adds to the file’s current mode, so it has no fixed octal value.

Good to know

  • Each digit is a sum of 4, 2 and 1. Read is 4, write 2 and execute 1, and the digits are owner, group and others (u, g, o in chmod). An optional leading digit holds the special bits: setuid 4, setgid 2 and sticky 1 (S_ISUID, S_ISGID and S_ISVTX in POSIX). A leading 0 means none, so 0755 comes back as 755. Missing leading digits are zeros, so 7 is 007.
  • Others never show s. Their execute slot carries the sticky bit (t or T), so rwxrwxrws is rejected.
  • On a directory the bits mean something else. Read lists names, write creates, deletes and renames entries (only with execute), and execute lets you enter it. Setgid makes new files take the directory’s group; sticky lets only a file’s owner, the directory’s owner or root delete or rename it, which is why /tmp is 1777.
  • Linux ignores setuid and setgid on #! scripts. Only compiled programs run as the file’s owner or group.
  • A numeric mode sets all nine permission bits at once. chmod u+x file changes one and keeps the rest.
  • GNU chmod keeps a directory’s setuid and setgid bits with a numeric mode. chmod 755 on a 2775 directory gives 2755. Clear them with chmod g-s dir, or with GNU’s five-digit chmod 00755 dir, which Command keeps as typed.
  • Paste only the mode column. The type letters -, d, l, c, b, p and s are dropped, and so is a trailing + (ACL), . (SELinux context) or @ (macOS extended attributes). A Linux symlink always shows lrwxrwxrwx, and chmod on it changes the target.
  • Limits. Input is up to 12 characters, with surrounding spaces ignored. Octal modes take 1 to 4 digits from 0 to 7, or 5 starting with 0; 8755 and 10755 are rejected.

Questions

What does chmod 755 mean?

It gives the owner read, write and execute, and gives the group and everyone else read and execute: rwxr-xr-x. It’s the usual mode for directories and executables; regular files usually get 644 (rw-r--r--), which the common umask 022 gives new files.

How do I convert rwxr-xr-x to octal?

Split it into three groups and add 4 for r, 2 for w and 1 for x in each: rwx is 7 and each r-x is 5, so it’s 755. If a slot shows s, S, t or T, put the special digit in front: rwsr-xr-x is 4755.

What do s, S, t and T mean in ls -l output?

They are the setuid, setgid and sticky bits, in the execute slot of the owner, the group and others respectively. Lowercase means execute is set too; uppercase means it isn’t.

How do I see a file’s permissions in octal?

On Linux, stat -c '%a' file prints it, such as 644 or 4755. On macOS and the BSDs, stat -f '%OLp' file prints the permission digits.