← Guides

Developer Guide

Unix File Permissions and chmod

Read rwx as 4-2-1, convert 644 and 755, and handle setuid, setgid, and the sticky bit. Build a pasteable chmod command in the browser — umask is not this tool.

chmod calculatorunix file permissionschmod 755chmod 644setuid setgid sticky

Unix permission bits are a 12-bit mode: nine rwx flags for owner, group, and other, plus setuid, setgid, and sticky. People remember 755 and 644 as folklore. The arithmetic is simpler than it looks: read is 4, write is 2, execute is 1, and you add them per class. /tools/chmod-calculator keeps octal, ls-style symbolic, chmod clauses, and a copyable command in sync. It does not apply a umask and it does not talk to your server.

The 4-2-1 nibble

Each of owner, group, and other is a 3-bit nibble. r = 4, w = 2, x = 1. Add the bits you want. Owner rw- is 4+2 = 6. Group r-- is 4. Other r-- is 4. Concatenate the three digits: 644, which ls -l prints as rw-r--r--.

Execute for a directory means “search”: you can cd into it and look up names. A file with 755 (rwxr-xr-x) is a program others can run. The same mode on a directory is the usual public folder. /tools/chmod-calculator defaults to 644 because that is the common file, not the common directory.

  • 644 / rw-r--r-- — ordinary file.
  • 755 / rwxr-xr-x — executable or directory others may traverse.
  • 600 / rw------- — private file (SSH keys).

ls output versus chmod clauses

ls -l prints ten characters. The first is the type (- file, d directory, l symlink). The next nine are permissions. Paste either the nine (rwxr-xr-x) or the ten (-rwxr-xr-x, drwxr-xr-x) into the calculator; the type letter is ignored because it is not part of the mode.

The other symbolic dialect is what chmod itself accepts: u=rwx,g=rx,o=rx. That is an assignment, not a listing. a=rwx is 777. u+s adds setuid without touching rwx. The calculator parses both dialects and emits chmod 755 file plus a clause form such as chmod u=rwx,g=rx,o=rx file.

setuid, setgid, and sticky

A fourth octal digit, written in front, holds special bits: 4 setuid, 2 setgid, 1 sticky. 4755 is rwsr-xr-x — owner execute becomes s because setuid is on and execute is on. If you set setuid without execute you get S (4644 → rwSr--r--). Sticky on a world-writable directory is 1777 / rwxrwxrwt (/tmp). Sticky without other-execute is T.

setuid on a binary runs it as the file owner. setgid on a directory makes new files inherit the directory’s group. Sticky on a directory means only a file’s owner (and root) can unlink it. Do not sprinkle these on a web root because a tutorial used four digits.

What the calculator will not do

Umask is a process mask, not a file mode. If your umask is 022, a 666 create becomes 644 on disk. The tool never subtracts a umask; it shows the mode you asked for. Windows ACLs, NFS idmap, and POSIX capabilities are also out of scope.

Octal 755 as decimal is 493. That conversion belongs on /tools/number-base-converter. Feeding 493 to chmod is a mistake. Stay in octal or symbolic when talking to chmod.

Presets worth using, and 777

The page ships presets: 644 files, 755 exec, 600 private, 700 private exec, 444 read-only, 664/775 for shared group trees, 4755 setuid, 2755 setgid, 1777 sticky. 777 is in the list so you can see rwxrwxrwx, not because a document root should be world-writable.

SSH private keys should be 600; ~/.ssh should be 700. World-writable web trees are a common breach path. Copy the command from the tool and run it on the host you intend — the browser cannot chmod a server.

Common pitfalls

Treating 755 as “the file mode” for everything, including secrets. Forgetting that directory execute is search. Pasting drwxr-xr-x into a script that expects three octal digits. Assuming the calculator applied your umask. Using chmod 777 to “make it work” on a shared host.

  • s means setuid/setgid with execute; S means the special bit without execute.
  • t / T is sticky, the same execute-present versus execute-absent rule.
  • The copyable command is chmod 755 file (or the clause form). It does not run until you paste it into a shell.

Worked examples

644 ordinary file

Input
owner rw-, group r--, other r--
Output
octal 644
symbolic rw-r--r--
chmod 644 file

The calculator’s default. Use this for config and source files that are not executables.

755 executable or directory

Input
u=rwx,g=rx,o=rx
Output
octal 755
symbolic rwxr-xr-x
chmod 755 file

Paste the clause or tick execute on all three classes. Octal 755 is not decimal 755.

4755 setuid

Input
4755
Output
symbolic rwsr-xr-x
chmod 4755 file
chmod u=rwx,g=rx,o=rx,u+s file

Owner execute shows as s, not x. Without owner execute the listing would use S.

Frequently asked questions

Is 755 a file mode or a directory mode?

Both, with different meanings. On a file it is executable by everyone. On a directory it is traversable. Default files are usually 644; default directories 755.

Why does ls show ten characters but chmod wants three or four digits?

The first ls character is the file type, not a permission. The next nine are rwx for owner, group, and other. Octal 755 encodes those nine bits; a leading 4, 2, or 1 adds setuid, setgid, or sticky.

Does the calculator apply my umask?

No. Umask is subtracted at create time on the host. /tools/chmod-calculator shows the mode you selected, then a command you can run.

Should I chmod 777 to fix a permission error?

No. World-writable trees are a common breach path. Find the user or group that should own the file and use 644, 755, 664, or 775 instead.

Does any of this leave the browser?

No. Checkboxes, octal, and symbolic stay in the tab. You still have to paste the command onto the machine that holds the file.

Summary

Add 4, 2, and 1 per class, prefix special bits when you truly need them, and prefer 644/755/600 over 777. /tools/chmod-calculator keeps octal, rwxr-xr-x, chmod clauses, and a copyable command aligned. Convert 755 to decimal 493 only on /tools/number-base-converter — never as an argument to chmod.

Try it yourself

Put what you've learned into practice with our free browser-native tool.

Open Tool →