What a Chmod Calculator Does
The chmod command sets who can read, write and run a file on Linux, macOS and other Unix systems. It takes the permissions as a number or as letters, and both forms are easy to get wrong. A chmod calculator lets you tick the permissions and shows the number, the letters and the finished command, so you do not have to add the digits in your head.
Everything on this page stays in sync. Change a box and the octal and symbolic fields update. Type in a field and the boxes follow. The calculator only builds the text of a command. It never touches a file.
How Linux File Permissions Work
Every file has three sets of permissions: one for the owner, one for the group and one for everyone else (called others). Each set has three switches. Read is worth 4, write is worth 2 and execute is worth 1. Add the values of the switches that are on and you get one digit from 0 to 7.
- 7 = 4 + 2 + 1: read, write and execute
- 6 = 4 + 2: read and write
- 5 = 4 + 1: read and execute
- 4: read only
- 0: no access
Three digits, one for each set, make the octal mode. In 755 the owner has 7, the group has 5 and others have 5. The letters form is the same information written as rwxr-xr-x, where a dash means the switch is off. For 755 the tool prints:
Octal: 755
Symbolic: rwxr-xr-x
Command: chmod 755 file
Owner: read, write and execute
Group: read and execute
Others: read and executeOn a directory the switches mean something slightly different. Read lets you list the names inside, write lets you add and remove files, and execute lets you enter the directory and reach the files in it. That is why directories usually need the execute bit and plain files do not.
Read the ls -l String Such as drwxr-xr-x
When you run ls -l, each line starts with ten characters. The first one is the type: a dash for a file, d for a directory and l for a symbolic link. The other nine are the permissions in the letters form. So drwxr-xr-x is a directory with mode 755, and -rw-r--r-- is a file with mode 644.
Paste either form into the Symbolic field. A string with ten characters has its type letter ignored, because the type is not part of the mode. The ls -l style line in the Result section lets you choose File, Directory or Symlink for the first character.
Chmod 755 vs 644 and Other Common Modes
Most files on a server use one of a handful of modes. Use the buttons under Common modes to load them.
- 644 (rw-r--r--): the usual mode for web pages, configuration and documents. The owner edits them and everyone else can read them.
- 755 (rwxr-xr-x): the usual mode for programs, scripts and directories. The owner has full access and everyone else can read and run.
- 600 (rw-------): private files such as SSH private keys. Only the owner can read or write. SSH refuses to use a private key that others can read.
- 700 (rwx------): private directories, such as the .ssh folder.
- 664 and 775: the shared versions of 644 and 755, where the group can write as well.
- 400 (r--------): read-only, even for the owner, until the mode is changed back.
The difference between 755 and 644 is the execute bit. A script needs it to be run directly, and a directory needs it to be entered. A data file does not.
Why Chmod 777 Is a Bad Idea
The mode 777 gives read, write and execute to every user on the system. Any account, including one used by a compromised program, can then change or replace the file. It is often suggested as a quick fix for a permission error, but it hides the real problem, which is usually the wrong owner or group.
The calculator shows a warning for 777 and for any mode that others can write to. A better fix is to give the file to the right user with chown, or to use 775 for a shared group. If the web server needs to write to one folder, make that single folder writable instead of the whole site.
Setuid, Setgid and the Sticky Bit
A fourth digit in front of the three, as in 4755, holds the special bits. Setuid is worth 4, setgid is worth 2 and the sticky bit is worth 1. In the letters form they replace an x: an s in the owner or group position, and a t in the others position. A capital S or T means the special bit is on while the execute bit under it is off.
- Setuid (4): a program runs with the permissions of its owner instead of the user who starts it. The passwd command works this way.
- Setgid (2): a program runs with the permissions of its group. On a directory, new files get the directory's group, which is useful for shared folders such as mode 2775.
- Sticky bit (1): in a shared directory such as /tmp (mode 1777), only the owner of a file can delete or rename it.
For 4755 the tool prints rwsr-xr-x and adds a line that explains setuid. Use these bits carefully. A setuid program that others can write to is a serious security hole.
Chmod Symbolic Mode: u+x, go-w and g=rx
Besides numbers, chmod accepts changes in letters. Start with who: u for the owner (user), g for the group, o for others and a for all. Then an operator: plus adds a permission, minus removes it and equals sets it exactly. Then the permissions r, w, x, s or t. Several changes can be joined with commas.
- u+x adds execute for the owner. Applied to 644 it gives 744.
- go-w removes write from the group and others. Applied to 666 it gives 644.
- g=rx sets the group to read and execute only, whatever it was before.
- a+x or +x adds execute for everyone.
Type a change in the Change the current mode field and press Apply change. The calculator applies it to the mode shown in the grid. If you type a change in the Symbolic field instead, it is applied to a mode of 000, so u=rwx,g=rx,o=rx gives 755.
How Umask Sets Default Permissions
A umask is a mask that removes permissions from new files and directories. New files start from 666 and new directories start from 777. The bits that are set in the umask are taken away. Files do not start with execute, so a new file never becomes executable by accident.
With the common umask 022, new files get 644 and new directories get 755. With umask 077 new files get 600 and new directories get 700, so only the owner can use them. The Umask calculator shows both results for any umask and can send the result to the main calculator.
The umask affects only files created after it is set. It does not change files that already exist. Use chmod for those. When you set permissions for a scheduled job, the Cron Expression Generator helps with the schedule, and the script it runs normally needs mode 755 or 700.
Limits and Privacy
This tool does not cover access control lists, file ownership (chown) or Windows permissions. It follows the standard Unix rules for the nine permission bits and the three special bits. The behavior of the special bits can differ a little between systems, so check the manual page for chmod on yours.
The calculator runs in your browser. Nothing you type is sent to a server or stored. See the Privacy Policy for details. If you also work with web addresses, the URL Parser splits a link into its parts, and the SQL Query Optimizer helps with database work.