Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

chmod Calculator

ReadWriteExecuteOwnerGroupOthersSpecial
Ready
Runs in your browser. Nothing you paste is uploaded unless you share it.

Read a Unix mode from 755, rwxr-xr-x, an ls -l line or a chmod command and write it every way, umask and special bits too

Type a mode or paste an ls -l line to see who can read, change and run the file, the mode in octal, letters and chmod’s own words, and what deserves a second look.

How to use it

  1. Type a mode like 755, paste the start of an ls -l line, or a whole chmod command; the page finds the mode in it. Short modes are read as chmod reads them: 7 is 007. To take rights away (g-w), write the current mode after it: g-w 775.
  2. Tick boxes in the grid to change it. The change is written back the way you typed it: octal stays octal, an ls line stays an ls line.
  3. Pick File or Directory: read, write and execute mean different things on a directory.
  4. Tick chmod’s options (-R, -v, -c, -f, --preserve-root) to add them to the command, or pick from More modes for 22 common modes.

Examples

An ls -l line

Input
-rwxr-x--- 1 ada staff 4096 Oct 4 10:20 deploy.sh
Result
Octal    750
Clauses  u=rwx,g=rx,o=
Owner    read, change and run it
Group    read and run it
Others   nothing

A mode with the setuid bit

Input
4755
Result
ls -l    -rwsr-xr-x
Clauses  u=rwx,g=rx,o=rx,u+s

The s where the owner’s x would be is setuid. /usr/bin/passwd has this mode on most Linux systems.

chmod’s own words

Input
chmod u=rw,go=r notes.txt
Result
644  rw-r--r--

Take a right away from the current mode

Input
u+x,go-w 666
Result
744  rwxr--r--

chmod changes the file’s current mode, so - needs it: here 666, the mode a new file gets with umask 000.

How the three digits work

Each digit is one class: the owner, the file’s group, then everyone else. Within a digit, read is 4, write is 2 and execute is 1, added up: 7 is all three, 5 is read and execute, 4 is read only, 0 is nothing. So 755 is rwx for the owner and r-x for the rest.

Models -lUsed for
644-rw-r--r--ordinary files: web pages, config, documents
755-rwxr-xr-xscripts and programs; most directories
600-rw-------private files: an SSH private key, a .env file
700drwx------a private directory, like ~/.ssh
664-rw-rw-r--files a team edits together
400-r--------a key or certificate no one should change
1777drwxrwxrwt/tmp: anyone can add files, only owners delete them

On a directory, the rights mean something else

Read lets you list the names inside. Execute lets you open the directory and reach what is in it, so a directory without x can’t be entered even when you can read it. Write lets you add, delete and rename files inside, and needs x to work. That is why directories are usually 755 or 700, not 644 or 600.

chmod’s options

chmod -R changes a directory and everything in it to the same mode, so files get the execute bit a directory needs. To give folders 755 and files 644, use find with -type d and -type f: for a directory the page writes both, the files’ mode without execute.

OptionWhat it doesmacOS and BSD
-Revery file and directory inside, tooyes
-vprints a line for each fileyes
-cprints a line only for files it changedno
-fsays nothing when a file can’t be changedyes
--preserve-rootrefuses to work on / with -Rno
--reference=FILEcopies FILE’s mode instead of a typed oneno

Sources: GNU coreutils: chmod

Setuid, setgid and the sticky bit

A fourth digit in front sets the special bits: 4 is setuid (a program runs as its owner), 2 is setgid (it runs as its group; on a directory, new files take the directory’s group) and 1 is sticky (in a shared directory, only a file’s owner can delete or rename it). ls shows them as s or t in the execute place, in capitals when execute itself is off.

Questions

What does chmod 777 do, and why is it a bad idea?
It gives everyone on the machine read, write and execute. Any user or process can change or replace the file, so a script or a web page can be swapped for something else. 755 for programs and directories, 644 for files is usually what’s meant.
What is the difference between chmod 755 and chmod +x?
755 sets the whole mode at once. +x only adds execute and leaves read and write as they were; without u, g or o in front, chmod adds it for every class the umask allows. This page assumes umask 022 for that and says so.
What umask gives 755 directories and 644 files?
umask 022. A umask takes rights away from 777 for new directories and from 666 for new files, so 022 gives 755 and 644, and 027 gives 750 and 640.
How do I chmod only folders, or only files?
With find: find folder -type d -exec chmod 755 {} + sets every directory, and find folder -type f -exec chmod 644 {} + every file. chmod -R alone gives both the same mode.
Is the mode I type uploaded?
No. Everything runs in your browser, so your modes and file names stay on your device. Nothing you paste is uploaded unless you share it.

Related tools