Skip to the content

Chmod Calculator

Tick read, write and execute to get the numeric and symbolic Unix permissions.

Read (4)Write (2)Execute (1)Digit
Owner7
Group5
Others5

A program runs with the rights of the file's owner.

A program runs with the file's group. In a directory, new files get the directory's group.

In a directory, users can't delete or rename each other's files.

Owner can read, write and execute. Group and others can read and execute.

chmod 755 file
chmod u=rwx,g=rx,o=rx file

Common values

Share this tool:TwitterFacebookLinkedInWhatsAppEmail

How the number is built

A file has three sets of permissions: one for its owner, one for its group and one for everybody else. Each set is a single digit, the sum of read (4), write (2) and execute (1).

DigitLettersSum
7rwx4 + 2 + 1
6rw-4 + 2
5r-x4 + 1
4r--4
0---nothing

So 640 is 6 for the owner (read and write), 4 for the group (read) and 0 for others: rw-r-----. The digits 3, 2 and 1 (-wx, -w-, --x) exist too, but are rare.

You can paste the permissions from ls -l straight into the symbolic field, with or without the first character that gives the file type.

The same bits mean something else on a directory

On a fileOn a directory
ReadRead its contentsList the names in it
WriteChange its contentsCreate, rename and delete files in it
ExecuteRun it as a programEnter it and reach the files inside

This is why a directory almost always has execute wherever it has read: without it you can see the names and nothing else. It also explains why you can delete a file you aren't allowed to write to. Deleting changes the directory, so the directory's permissions decide.

A script needs read as well as execute, because the interpreter has to open the file. A compiled program runs with execute alone.

Usual values

ModeUsed for
644Ordinary files: the owner edits, everyone can read
755Directories, and programs and scripts that anyone may run
600Private files. SSH refuses to use a private key that others can read
700Private directories such as ~/.ssh
664, 775Files and directories that a group works on together

New files get their mode from the umask. With the common umask of 022, files are created as 644 and directories as 755.

The fourth digit

A digit in front sets three special bits, added up the same way.

  • Setuid (4): a program runs with the rights of the file's owner instead of the user who starts it. passwd is the standard example. Linux ignores the bit on scripts.
  • Setgid (2): a program runs with the file's group. On a directory, new files inherit the directory's group, which keeps a shared folder consistent.
  • Sticky (1): in a directory, a file can only be deleted or renamed by its owner, the directory's owner or root. /tmp is 1777 for that reason.

In ls -l they take the place of the x: rwsr-xr-x is 4755, rwxr-sr-x is 2755 and rwxrwxrwt is 1777. A capital S or T means the special bit is set but the execute bit under it is not.

One GNU quirk: chmod 755 on a directory leaves a setgid or setuid bit that is already there in place. To remove it, say so with chmod g-s or chmod u-s.

Before you reach for 777

A "permission denied" error usually means the file belongs to the wrong user or group, and chown or chgrp is the fix. 777 makes the error go away by letting every account on the machine change the file.

See all 12