Chmod calculator (Linux file permissions)

Each chmod digit adds read (4), write (2) and execute (1) for the owner, the group and everyone else, so 755 is rwxr-xr-x and 644 is rw-r--r--. Tick the permissions or type a mode in either form to get the other forms and the exact command.

Octal mode

755

rwxr-xr-x

Symbolic
rwxr-xr-x
Four-digit octal
0755
Command
chmod 755 file
Command, symbolic form
chmod u=rwx,go=rx file
Owner (u)
read, write and execute
Group (g)
read and execute
Others (o)
read and execute
In binary
111 101 101

How do chmod permission numbers work?

Each digit of a chmod mode is a sum: read is 4, write is 2 and execute is 1. The three digits apply, in order, to the file's owner, its group and everyone else, so 7 (4 + 2 + 1) is rwx, 5 (4 + 1) is r-x and 755 is rwxr-xr-x. ls -l prints the same nine permissions as letters, with a dash for each one that is off.

An optional fourth digit in front holds the special bits: setuid is 4, setgid is 2 and the sticky bit is 1. In the letters they take the execute slot: s for setuid or setgid with execute on and S without it, and t or T in the others' slot for the sticky bit. So 4755 is rwsr-xr-x and 1777 is rwxrwxrwt.

On a folder the same letters mean different things: read lets you list what is in it, write lets you create and remove files in it, and execute lets you open the files inside. GNU chmod also keeps a folder's existing setuid and setgid bits when you give a mode like 755; use chmod 00755 or chmod =755 to clear them.

digit = read (4) + write (2) + execute (1)
mode = [special] owner group others
special = setuid (4) + setgid (2) + sticky (1)

Which chmod mode should I use?

Common chmod modes, their letters as ls -l shows them, and what each is typically used for
OctalSymbolicTypical use
644rw-r--r--Ordinary files such as web pages, images and config files: the owner edits, everyone reads
600rw-------Private files such as SSH private keys: only the owner reads or writes (ssh ignores a private key others can access)
640rw-r-----Files one group must read and nobody else may see
664rw-rw-r--Files a team group edits together
400r--------Secrets the owner reads but should not change by accident
755rwxr-xr-xFolders, and scripts or programs everyone may run but only the owner may change
750rwxr-x---Folders and programs for the owner and one group only
700rwx------Private folders such as ~/.ssh, and scripts only the owner runs
775rwxrwxr-xShared folders where a group adds and removes files
777rwxrwxrwxAlmost never right: anyone on the machine can change or replace the contents
1777rwxrwxrwtShared scratch folders such as /tmp: anyone adds files, only each file's owner deletes them
2755rwxr-sr-xA folder whose new files take the folder's group; only the owner adds files
2775rwxrwsr-xTeam folders: the group adds files and every new file takes the folder's group
4755rwsr-xr-xPrograms that must run with their owner's rights (setuid); keep these rare

How to work out a chmod command

  1. 1
    Choose how to enter the permissionsTick boxes, type an octal mode such as 755, or type letters such as rwxr-xr-x or u=rwx,go=rx.
  2. 2
    Set the permissionsTick read, write and execute for the owner, the group and others, plus any special bit you need, or type the mode in the field.
  3. 3
    Name the file or folderType its name so the command is ready to run; names with spaces are quoted for you.
  4. 4
    Copy the commandCopy chmod 755 file or its symbolic form into your terminal. The result also spells out who can read, write and execute.

Frequently asked questions

What does chmod 777 do and why is it risky?
It gives the owner, the group and every other account on the machine read, write and execute permission. Any user or compromised process on the server can then change or replace the file, so keep write access to the owner (755 or 644) or to a group that needs it (775).
What is the difference between chmod 755 and chmod 644?
755 (rwxr-xr-x) lets the owner write and everyone read and execute, which suits folders and scripts. 644 (rw-r--r--) is the same without execute, which suits ordinary files; on a folder it would stop even the owner from opening the files inside.
What do s, S, t and T mean in ls -l permissions?
They show the special bits in an execute slot. s is setuid (owner slot) or setgid (group slot) with execute on, and S is the same bit with execute off; t in the others' slot is the sticky bit with execute on, and T is the sticky bit without it.
How do I set 755 on folders and 644 on files in one go?
Run find . -type d -exec chmod 755 {} + and then find . -type f -exec chmod 644 {} +, so each type gets its own mode. chmod -R 755 would make every file executable; chmod -R u=rwX,go=rX also works, because capital X adds execute only to folders and to files that are already executable.
What does chmod +x do?
It adds execute permission so the file can be run as a program, for example ./deploy.sh. With no u, g, o or a in front, chmod adds it for everyone except the bits your umask masks; use u+x to add it for the owner only.

Sources

Related tools

See all 73 free tools

Need a custom dev tool for your team?

We build internal tools, dashboards, APIs, and SaaS platforms. If you can describe it, we can ship it.

Built by CountryDevs · No signup · No ads · We count visits, never what you enter