Chmod calculator: convert numbers to rwx permissions

Version 1.0.0

Type a chmod number such as 755, or tick the permissions you want, to see the matching rwx letters and a chmod command.

Nothing here touches your files. The command uses a placeholder path for you to replace.

Examples
Owner
Group
Others
Special bits

How to read the result

The mode always shows four digits. The first one holds the special bits, so 755 shows as 0755. For a file, both mean the same thing.

The nine letters match what ls -l prints after its first character. That first character is the file type, such as - for a file or d for a directory.

The field takes numbers only. To turn letters such as rwxr-x--- into a number, tick the matching boxes.

A config file only you and your group can read

Example

You want to edit the file, let your group read it, and keep everyone else out. Tick owner read and write, and group read.

The result is 0640, shown as rw-r-----. Owner is 6 (4 + 2), group is 4, and others is 0.

Before you run the command, check the real target with ls -ld path/to/file. It shows the type, owner, group, and current permissions.

How do chmod numbers work?

Each digit adds up three values: read is 4, write is 2, and execute is 1. The three digits are for the owner, the group, and everyone else, in that order.

One permission digit

Formula

read (4) + write (2) + execute (1)

DigitLettersPermissions
7rwxRead, write, and execute
6rw-Read and write
5r-xRead and execute
4r--Read only
3-wxWrite and execute
2-w-Write only
1--xExecute only
0---Nothing

So 755 gives the owner everything and lets the group and others read and execute. A fourth digit in front adds the special bits, covered below. The GNU chmod manual defines these values.

What do 644, 755, 600, and 777 mean?

These are the modes you'll see most. They're common patterns, not rules. Give a file the fewest permissions that still let its program work.

  • 644 (rw-r--r--): ordinary files and web pages. You edit, everyone reads.
  • 755 (rwxr-xr-x): directories, scripts, and programs. You edit, everyone reads and runs.
  • 640 (rw-r-----): config files a service's group must read. Others get nothing.
  • 600 (rw-------): private keys and password files. Only you.
  • 700 (rwx------): private directories such as ~/.ssh. Only you.
  • 777 (rwxrwxrwx): rarely right. Anyone on the system can change it.

Some programs check this for you. ssh ignores a private key that other users can access.

Why do directories need execute permission?

On a directory, execute means you can enter it and reach the files inside by name. Read only lets you list the names.

PermissionOn a fileOn a directory
ReadRead the contentsList the names inside
WriteChange the contentsAdd, delete, or rename entries, with execute also set
ExecuteRun it as a programEnter it and open entries by name

This is why one mode for a whole folder tree goes wrong. chmod -R 644 leaves directories without execute, so no one but root can open the files inside. chmod -R 755 makes every file executable.

GNU chmod's capital X handles mixed trees: a+X adds execute only to directories and to files that someone could already execute. See conditional executability.

Deleting a file depends on the directory's write permission, not the file's. A read-only file can still be deleted from a folder you can write to.

What do s, S, t, and T mean in permissions?

They mark the special bits, which sit in the first of the four digits. Each letter takes the place of an x: setuid in the owner's spot, setgid in the group's, and sticky in others'.

Special bit (first digit)LettersWhat it does
Setuid (4)s/SA program runs with its owner's user ID
Setgid (2)s/SA program runs with its group's ID. On a directory, new files get the directory's group.
Sticky (1)t/TOn a directory, only a file's owner, the directory's owner, or root can delete or rename it

Lowercase means the execute bit is also set. Uppercase means it isn't. So 4640 shows as rwSr-----: setuid is on, but the owner can't execute. The GNU ls manual lists these letters.

You'll see two of these on real systems. /tmp is usually 1777 (rwxrwxrwt), so anyone can write there but can't delete other people's files. A shared folder set to 2775 keeps every new file in the folder's group. The Linux inode manual describes both.

Why can't I access a file when the permissions look right?

The mode is only one part of access. These also decide it:

What else countsWhat to check
Owner and groupThe owner digit applies only to the user who owns the file. Compare the owner in ls -l with the user your program runs as.
Parent directoriesYou need execute on every directory in the path, not just the last one.
ACLsA + after the letters in ls -l means extra rules for named users or groups. getfacl shows them. See the Linux ACL manual.
Mount optionsA filesystem mounted read-only blocks writes, and one mounted noexec blocks running programs, whatever the mode says.
ContainersIn an unprivileged container, files owned by an unmapped user show up as nobody (ID 65534). The LXC ID mapping checker checks those mappings.

Is umask the same as chmod?

No. Umask removes permissions when a file is created. chmod sets them on a file that already exists.

The usual umask is 022. A program that creates a file with 666 gets 644, and a directory created with 777 gets 755. Changing the umask doesn't touch existing files. See the Linux umask manual.