Chmod calculator
setuid runs a program with its owner’s rights. setgid on a folder gives new files the folder’s group. sticky lets only a file’s owner delete it from a shared folder like /tmp.
chmod 755 file
chmod u=rwx,g=rx,o=rx file
-rwxr-xr-x
How chmod permissions work
Every file and folder on Linux and macOS has three sets of permissions: one for its owner, one for its group and one for everyone else. Each set is read, write and execute. chmod changes them, either with a number such as 755 or with letters such as u=rwx,g=rx,o=rx. Both describe the same thing, and this calculator turns one into the other.
How to use it
- 1 Start from whatever you have: tick the boxes, type a number like 644, or paste the letters from ls -l such as -rw-r--r--.
- 2 The other two fields follow instantly. The big digit above each column shows how that class adds up: read 4 + write 2 + execute 1.
- 3 Type your file or folder name and copy the command you prefer. The numeric form sets all bits at once; the letter form is easier to read in scripts.
Reading the three digits
Each digit is one class: owner, group, others, in that order. Inside a digit, read is 4, write is 2 and execute is 1, so 7 = rwx, 6 = rw-, 5 = r-x and 4 = r--. 755 is therefore not a quantity; it is three separate answers. That is also why 8 and 9 never appear: no combination of 4, 2 and 1 goes above 7.
Folders need execute too
On a folder the letters mean something else. Read lets you list the names inside, write lets you create, rename and delete entries, and execute lets you enter the folder and open anything in it. A folder set to 644 shows its file names but refuses to open any of them, which is why web folders use 755 while the files inside use 644. Running chmod -R 755 on a whole site makes every file executable as well; chmod -R u=rwX,go=rX is safer, because capital X adds execute only to folders and to files that were already executable.
setuid, setgid and sticky: the fourth digit
A fourth digit in front holds the special bits: 4 for setuid, 2 for setgid, 1 for sticky, so 4755 is 755 plus setuid. In the letters they take the place of an x. A lowercase s or t means the special bit and execute are both on; an uppercase S or T means the special bit is on but execute is off, which is almost always a mistake, because a setuid program nobody can run does nothing. /tmp is the classic 1777 (rwxrwxrwt), and passwd is the classic 4755 (rwsr-xr-x).
Why 777 is the wrong fix
When an upload or a cache folder fails with "permission denied", 777 makes the error go away because it gives write access to every account on the machine. On a shared or compromised server that means any process can replace your scripts with its own code. The real fix is usually ownership: make the web server user the owner (chown) or put it in the group and use 775 for folders and 664 for files. New files get their starting permissions from the umask; the common umask 022 turns 666 into 644 for files and 777 into 755 for folders.