$ man chmod-calculator
Chmod Calculator
NAME
chmod-calculator — Convert between chmod octal, rwxr-xr-x symbolic notation and permission checkboxes, with setuid, setgid and sticky bits and the chmod command to copy.
SYNOPSIS
# What is a chmod calculator?
A chmod calculator converts between the three ways a Unix file mode is written — the permission checkboxes, the octal number such as 755, and the symbolic string such as rwxr-xr-x — including the setuid, setgid and sticky bits and the s, S, t and T characters that `ls -l` uses to show them.
WHY HERE
Developer utilities for people building with APIs.
| Class | Octal | Letters | What it permits |
|---|---|---|---|
| Owner | 7 | rwx | can read the contents, modify or truncate it, run it as a program. |
| Group | 5 | rx | can read the contents, run it as a program. |
| Others | 5 | rx | can read the contents, run it as a program. |
Mode bits are only part of Unix access control and may not be the part that decides. ACLs (getfacl/setfacl), SELinux or AppArmor labels, file attributes such as chattr +i, mount options like noexec, nosuid and read-only, container namespace mappings, and NFS or SMB permission mapping can all override or further restrict what these bits suggest. The umask governs the mode a new file gets, which is a separate question. Root generally bypasses these checks entirely. Nothing is executed here — the command above is text for you to copy and run.
// Mode bits are only part of Unix access control, and on a real system they may not be the part that decides. Access-control lists (getfacl/setfacl), SELinux or AppArmor labels, file attributes (chattr, such as the immutable flag), mount options like noexec, nosuid and read-only, container and namespace mappings, and NFS or SMB server-side permission mapping can all override or further restrict what these bits suggest. The umask decides the mode a newly created file gets, which is a separate question. Root generally bypasses permission checks altogether. Nothing you type here is stored or sent anywhere, and nothing is executed — the chmod command shown is text for you to copy and run yourself.
USAGE
01 → Edit whichever notation you have
Tick the boxes, type an octal mode, or paste a symbolic string — all three stay in step. You can paste a whole `ls -l` permission field including its leading d or -, and the type character is stripped for you.
02 → Say whether it is a directory
This changes what the answer means, not just the wording. On a directory the execute bit grants traverse, not execute, and the sticky bit stops people deleting each other's files. On a regular file the sticky bit does nothing at all on any modern Unix.
03 → Watch the execute column when a special bit is set
`ls -l` has no columns of its own for setuid, setgid and sticky — it overloads the three execute positions. A lower-case s or t means the special bit and the execute bit are both set; a capital S or T means the special bit is set with no execute bit under it, so it does nothing.
04 → Use the four-digit octal when a special bit is involved
`chmod 755` clears any special bits that were there. If you mean to keep or set them you need the four-digit form, `chmod 4755`. The tool shows both and uses the four-digit one in the command when it matters.
DESCRIPTION
A Unix file mode is twelve bits in four groups of three. The last three groups are read, write and execute for the owner, the group and everyone else, worth 4, 2 and 1 — so rwx is 7, rw- is 6, r-x is 5 and r-- is 4, and 755 is the familiar rwxr-xr-x. The first group holds setuid (4), setgid (2) and the sticky bit (1), which is why a mode can have a fourth digit: 4755 is rwsr-xr-x with setuid set.
The part that catches people is how `ls -l` displays those special bits. It has no columns to spare, so it overloads the three execute positions, and it uses case to tell you whether the underlying execute bit is also set. Setuid with owner-execute is `s`; setuid without it is `S`. Setgid with group-execute is `s`; without, `S`. The sticky bit with other-execute is `t`; without, `T`. So 4755 reads rwsr-xr-x, 4655 reads rwSr-xr-x, 1777 reads rwxrwxrwt — that is /tmp — and 1776 reads rwxrwxrwT. A capital letter is always a warning sign: the bit is set but inert.
On a directory the execute bit is misnamed. It does not mean execute; it means traverse — permission to resolve a path through the directory and to stat the entries inside it. The two halves come apart in a way that is genuinely useful: a directory with r and no x lists its filenames and can tell you nothing else about them, while a directory with x and no r lets you open a file whose name you already know but gives you no way to discover it. That second combination, mode 711, is how a home directory is locked down while still allowing a web server to reach ~/public_html.
The special bits are where the security sits. setuid makes a program run with its owner's privileges rather than the caller's — that is how `passwd` can edit /etc/shadow — and a setuid root binary that is also writable by anyone other than root is a straightforward privilege escalation. setgid on a directory makes new files inherit the directory's group, which is the standard way to run a shared project tree. The sticky bit on a world-writable directory means only a file's owner can delete it, which is the only reason a world-writable /tmp is survivable. And 777 is almost never the right answer: it means any process on the machine, including anything that has already found a foothold, can rewrite the file.
FAQ
## What does chmod 755 mean?
rwxr-xr-x: the owner can read, write and execute; the group and everyone else can read and execute but not write. It is the usual mode for a directory or an executable script. Note that `chmod 755` also clears any setuid, setgid or sticky bit that was set.
## How is the octal mode calculated?
Each class gets one digit from read = 4, write = 2, execute = 1, added together. rwx = 4+2+1 = 7, rw- = 6, r-x = 5, r-- = 4. The optional leading digit is setuid = 4, setgid = 2, sticky = 1 added the same way, so 4755 is setuid plus rwxr-xr-x.
## What is the difference between s and S in a file mode?
Lower-case s means the special bit and the execute bit are both set, so the special bit actually takes effect. Capital S means the special bit is set but there is no execute bit under it, so it does nothing. Same relationship between t and T for the sticky bit.
## What does the sticky bit do?
On a directory, it restricts deletion and renaming to a file's own owner, even where others have write permission on the directory. That is why /tmp is mode 1777: anyone can create files, nobody can remove anyone else's. On a regular file it does nothing on any modern Unix.
## Is chmod 777 ever correct?
Almost never. It lets any process on the machine modify the file, including anything that has already compromised another account. The usual reason people reach for it is a permissions problem they have not diagnosed; 644 for files, 755 for directories, and fixing the owner or group with chown is nearly always the real answer.