Chmod Calculator

Work out Linux file permissions both ways. Tick read, write and execute for the owner, the group and everyone else to get the octal mode and the command to run — or paste 755, rwxr-xr-x, u+x or a whole ls -l line and see exactly what it means.

Worked out in your browser · nothing is sent anywhere · POSIX and GNU coreutils behaviour
Files
Directories

Type 755, paste rwxr-xr-x or a whole ls -l line, or change the mode with u+x or go-w.

Type
Read4Write2Execute1Digit
Owner4+2+1=7
Group4+1=5
Everyone else4+1=5
Specialnothing=0

In plain words

  • The owner can read it, change it and run it.
  • The group and everyone else can read it and run it.
  • This file can be run.

Worked out in your browser. Nothing is sent anywhere.

What does chmod do?

chmod sets who may read, write and run a file. A mode is twelve bits, usually written as three or four octal digits: 755, 644, 2775.

Each of the three digits belongs to a class — the file's owner, the file's group, and everyone else — and each digit is the sum of three numbers: read is 4, write is 2, execute is 1. So 7 is read, write and execute; 5 is read and execute; 6 is read and write; 4 is read only. That is the whole system. chmod 755 script.sh says: owner 7, group 5, others 5.

The fourth digit, when there is one, carries the three special bits — setuid 4, setgid 2 and the sticky bit 1 — and is left out when none of them is set. The calculator above shows all four digits at once and the arithmetic behind each, so you can stop looking the numbers up.

A mode is twelve bitschmod 755 script.sh
Beforescript.sh
Specials4s2t10
Ownerr4w2x16
Groupr4w2x14
Everyone elser4w2x14
-rw-r--r--0644
Afterscript.sh
Specials4s2t10
Ownerr4w2x17
Groupr4w2x15
Everyone elser4w2x15
-rwxr-xr-x0755
chmod 755 sets every bit of the mode at once: from 644, that turns on the three execute bits, one for each class. Each class's three bits add up to one octal digit.
Chmod calculator showing mode 755 as a permission grid, its octal digits, the symbolic form and the chmod commandChmod calculator showing mode 755 as a permission grid, its octal digits, the symbolic form and the chmod commandTick or typeThe grid and the fields are the same thing: change either and the rest follows.Every digit4 + 2 + 1 for each class, so the number stops being something to memorise.Paste anything755, rwxr-xr-x, u+x or a whole ls -l line — it reads all four.The commandBuilt from the mode you chose, with the right number of digits and a recursive form that does not flatten your files.What it meansA plain sentence, plus the warnings a mode deserves.
Mode 755 taken apart: the grid, the arithmetic behind each digit, the symbolic form and the command to run. Select a number to see what each part shows.

How Linux file permissions work

Every file has an owner, a group and a mode. The mode gives three permissions to each of three classes — nine bits — and right after the file-type character, ls -l prints exactly those nine characters.

-rw-r--r-- is a file (-) whose owner may read and write, and whose group and everyone else may only read: mode 644. drwxr-xr-x is a directory (d) at 755. The first character is the type: - a file, d a directory, l a symlink, and b, c, p or s for the special kinds. Paste any of those lines into the calculator and it reads the mode and the type out of it.

On a directory the three permissions mean something different from a file. Read lets you list the names in it. Execute lets you go into it and reach the files you already know the names of. Write, together with execute, lets you create and delete entries — which is why deleting a file depends on the directory's permissions, not the file's. A directory with read but no execute is a directory you can list and not open.

What ls -l prints firstls -l notes.txt
PermissionOn a fileOn a directory
r4Read what is in itList the names in it
w2Change what is in itCreate, rename and delete entries
x1Run it as a programGo into it and open what is inside

Other first characters: d a directory, l a symbolic link, and b, c, p or s for the special kinds.

What does chmod 755 mean?

755 means the owner can read, write and run the file, and everyone else can read and run it but not change it. It is the normal mode for a directory and for a program.

Digit by digit: 7 = 4 + 2 + 1, so the owner reads, writes and executes. 5 = 4 + 1 for the group and again for everyone else, so both read and execute. Written out it is rwxr-xr-x, and as a symbolic command chmod u=rwx,g=rx,o=rx.

Use it for directories you want people to be able to enter, and for scripts and binaries you want them to be able to run. Do not use it for anything secret: the last 5 means every account on the machine can read the file. For a web server's files, WordPress's own documentation recommends 755 or 750 for directories and 644 or 640 for files.

755, digit by digitchmod 755
7=r4w2x14+2+1rwxOwner
5=r4-2x14+1r-xGroup
5=r4-2x14+1r-xEveryone else
Use it for
  • Directories people need to go into
  • Scripts and programs
Not for
  • Anything secret: everyone can read it

WordPress's own documentation: directories 755 or 750, files 644 or 640.

chmod 644 vs 755: which one do I need?

644 for files, 755 for directories and for anything that has to run. The only difference is the execute bit.

644 is rw-r--r--: the owner can change it, everyone can read it, nobody can run it. That is right for HTML, CSS, images, configuration and source files. 755 is rwxr-xr-x: the same, plus the execute bit for all three classes. A directory needs it or nobody can enter the directory, and a script needs it or the shell will refuse to run it.

The mistake worth avoiding is chmod -R 755 over a whole site, which makes every image and every .php file executable. The two find commands the calculator writes give directories and files different modes in one pass, with the modes you actually chose rather than a pair from a blog post.

The only difference is the execute bit644 · 755
644
ReadWriteExecute
Ownerrw-6
Groupr--4
Othersr--4

Files: HTML, CSS, images, configuration, source code

755
ReadWriteExecute
Ownerrwx7
Groupr-x5
Othersr-x5

Directories, scripts and programs

The wrong way round
  • 755A file at 755 can be run, and so can every image and .php file under a chmod -R 755.
  • 644A directory at 644 shows its names, but nobody can go into it or open anything inside.

What does chmod 777 do, and is it safe?

777 lets every account on the machine read, change and run the file. It is almost never the right answer, and WordPress's own documentation says no directory should ever get it.

World-writable means anyone who can log in — or anything running as any user, including a compromised process — can replace the file's contents. If that file is a script the web server runs, you have handed over the server. WordPress's permissions page recommends 755 or 750 for directories and 644 or 640 for files, and says no directory should ever be 777, not even an upload directory.

When a web application cannot write to a directory, the fix is the owner or the group, not the mode: chown the directory to the user the web server runs as, or add that user to a shared group and use 775. The calculator warns whenever a mode lets everyone write: on a file always, and on a directory unless the sticky bit stops people deleting each other's files.

Who can write at 777chmod 777
777Everyone can change it
ReadWriteExecute
Ownerrwx7
Grouprwx7
Othersrwx7
  1. 1Any account, or any process running as one
  2. 2replaces the script
  3. 3and the web server runs it
What the documentation asks for

WordPress · Directories 755 or 750, files 644 or 640.

“No directories should ever be given 777, even upload directories.”

The fix is the owner or the group, not the mode: chown it to the web server's user, or share a group and use 775.

Why does SSH say my key permissions are too open?

OpenSSH refuses to use a private key that anyone but its owner can read. Set the key to 600 and the .ssh directory to 700.

The exact message is Permissions 0644 for '<path>' are too open., followed by It is required that your private key files are NOT accessible by others. The test behind it is blunt: if you own the file and any group or other bit is set, the key is refused. That is why 640 fails too, and why 600 is the answer rather than "a bit less than 644".

chmod 600 ~/.ssh/id_ed25519 and chmod 700 ~/.ssh fix it. The public key may be readable by anyone — only the private key and the directory matter here. Pick SSH key under the common modes above and the calculator writes both commands for you.

What ssh prints
$ssh you@server.example
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/you/.ssh/id_ed25519' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
What OpenSSH checks
The files, and the modes that pass
  • ~/.ssh/700drwx------The directory
  • id_ed25519600-rw-------Your private key
  • id_ed25519.pub644-rw-r--r--The public key: anyone may read it
  • config600-rw-------Not writable by others
The test, bit by bit
  • 644rw-r--r--Refused
  • 640rw-r-----Refused
  • 600rw-------Used
  • 400r--------Used

Group and everyone else: all must be off

Symbolic mode: u, g, o, a with +, - and =

chmod u+x script.sh adds one bit without touching the rest. + adds, - removes, = sets a class to exactly what you list.

The grammar is [who][op][permissions], with commas between clauses: u the owner, g the group, o everyone else, a all three. So go-w takes write away from the group and others, a=rwx sets everything, and u=rw,go=r is another way to write 644. Paste any of those into the calculator above and it shows which bits change, before and after.

Two parts of the grammar are easy to get wrong, and the calculator follows both. X — a capital X — adds the execute bit only to a directory, or to a file that is already executable somewhere, which is what makes chmod -R u=rwX,go=rX safe on a mixed tree. And a clause with no class at all, like +x, is not the same as a+x: the bits set in your umask are left alone, so with the usual umask of 022, chmod +rwx on a 644 file gives 755, where chmod a+rwx gives 777.

who · operator · permissionschmod u+x script.sh
  • uthe owner
  • gthe group
  • oeveryone else
  • aall three
  • +add
  • -take away
  • =set to exactly
  • rread
  • wwrite
  • xexecute
  • Xexecute, only on directories and on files that can already run
  • ssetuid or setgid
  • tsticky
Worked examples
ChangeBeforeAfter
u+x644rw-r--r--744rwxr--r--Execute for the owner, nothing else touched.
go-w775rwxrwxr-x755rwxr-xr-xWrite taken from the group and everyone else.
a=r755rwxr-xr-x444r--r--r--All three set to read, and nothing else.
u=rw,go=r777rwxrwxrwx644rw-r--r--Three clauses: another way to write 644.
+rwx644rw-r--r--755rwxr-xr-xNo class: the bits in the umask (022) are not set, so the group and everyone else get no write.
a+rwx644rw-r--r--777rwxrwxrwxWith a, the umask does not count: everything is set.
a+Xon a directory644rw-r--r--755rwxr-xr-xCapital X on a directory: execute added, because it is one.
a+Xon a file644rw-r--r--644rw-r--r--Capital X on a file nobody can run: nothing added.

Setuid, setgid and the sticky bit

The fourth digit. On a file, setuid and setgid change which account a program runs as. On a directory, setgid decides the group of new files and the sticky bit decides who may delete them.

Setuid (4000) on an executable makes it run as the file's owner rather than as you — passwd is installed setuid so that it can run with root's rights when you change your password. Setgid (2000) does the same for the group. On a directory, setgid does something different and much more useful: new files inside inherit the directory's group instead of the creator's, which is how a shared project folder stays shared. Linux documents no meaning for the setuid bit on a directory; on macOS and the BSDs it can make new files take the directory's owner, if the filesystem was mounted with that option.

The sticky bit (1000) on a directory stops people deleting each other's files: only the file's owner, the directory's owner or root may remove or rename an entry. /tmp is mode 1777 for exactly that reason — everyone may write in it, nobody may delete anyone else's work. On a regular file macOS and the BSDs ignore the sticky bit, and GNU's manual gives it a meaning there only on some older systems. One trap: chmod 755 somedir — or chmod 0755 somedir — does not clear a setgid bit that is already on a directory, because GNU chmod deliberately keeps them with any numeric mode of fewer than five digits — POSIX only requires the octal form to clear them on a regular file. Use g-s, or the five-digit chmod 00755, and the calculator writes the five-digit form for you whenever that is what you need.

Setuid4755

A program runs as the file's owner, not as you.

Linux-rwsr-xr-x root root /usr/bin/passwd

passwd is installed this way, so it runs with root's rights when you change your password.

On a directory: no documented meaning on Linux. On macOS and the BSDs, new files take the directory's owner if the filesystem was mounted with that option.

Setgid2775

In a directory, new files take the directory's group instead of yours.

Linuxdrwxrwsr-x you devs project/

A shared project directory stays shared: every new file belongs to the team.

On macOS and the BSDs a new file always takes its directory's group, with or without this bit.

Sticky1777

In a directory, only the file's owner, the directory's owner or root may delete or rename a file.

macOSdrwxrwxrwt root wheel /private/tmp

Everyone may write in /tmp, and nobody may delete anyone else's files.

On a file the sticky bit is ignored on macOS and the BSDs.

The GNU trap: chmod 755 on a directory leaves its setgid bit on.

$chmod 755 project → drwxr-sr-xClear it with five digits or with the letters:$chmod 00755 project → drwxr-xr-x$chmod g-s project → drwxr-xr-x

umask: what new files get

A new file starts at 666 and a new directory at 777, and every bit set in the umask is turned off. The usual umask of 022 gives 644 and 755.

umask is not a subtraction, it is a mask: every bit set in the umask is turned off in the mode the program asked for. With umask 077 a new file is 600 and a new directory 700 — private by default. With umask 002 you get 664 and 775: the group can write too.

A umask can never make a file executable, because the base mode for a file has no execute bits to begin with — only directories start from 777. That is why a script you have just created is never runnable until you say chmod +x. Switch to the umask tab above to see what any umask produces, and open either result straight in the calculator.

Turned off, bit by bitumask 022
A new file
Starts atrw-rw-rw-666
umask····w··w·022
Getsrw-r--r--644
A new directory
Starts atrwxrwxrwx777
umask····w··w·022
Getsrwxr-xr-x755
Common umask values
umaskNew fileNew directory
022644 rw-r--r--755 rwxr-xr-x
002664 rw-rw-r--775 rwxrwxr-x
027640 rw-r-----750 rwxr-x---
077600 rw-------700 rwx------

No umask can make a file executable: a new file starts with no execute bit to keep.

How to change a folder and everything in it

chmod -R 755 folder gives directories and files the same mode, which makes every file executable. Two find commands give each kind the mode it should have.

find folder -type d -exec chmod 755 {} + and find folder -type f -exec chmod 644 {} + walk the tree once each and set directories and files separately. The calculator writes both with the modes you have chosen, not a fixed pair. The + at the end batches the files into as few chmod runs as possible, which matters on a large tree.

The other safe way is the capital X: chmod -R u=rwX,go=rX folder adds execute only to directories and to files that can already run. And after any recursive change, stat -c '%a %n' folder/* reads back everything one level down.

One folder, four ways
The folderNow1234
site/755755644755755
index.html644755644644644
app.php644755644644644
deploy.sh755755644644755
img/755755644755755
logo.png644755644644644
  1. 1$chmod -R 755 siteEvery file can be run
  2. 2$chmod -R 644 siteNo folder can be entered
  3. 3$find site -type d -exec chmod 755 {} +$find site -type f -exec chmod 644 {} +Each kind gets its own modeA script loses its x too
  4. 4$chmod -R u=rwX,go=rX siteEach kind gets its own modeA file that could already run keeps its x

Is there a chmod on Windows?

Not the same thing. Windows uses access control lists, and icacls is the nearest command: icacls file /grant Users:(RX).

NTFS permissions are a list of entries, each naming a user or group and the rights it has, so there is no single three-digit number to calculate. The nearest translation is per class: read becomes R, read and execute RX, write W, and execute on its own becomes the specific right X; a digit that needs two rights lists both — 7 is (RX,W). No digit is Modify (M), which also allows deleting, or Full control (F), which also allows changing permissions and taking ownership. The calculator shows that mapping beside your mode, and it is a nearest fit, not an equivalent.

Inside the Windows Subsystem for Linux, chmod works properly on the Linux filesystem. On a Windows drive mounted under /mnt/c it only works when that drive is mounted with the metadata option. Without it the mode is worked out from your Windows rights, the same for owner, group and everyone else, and chmod can do little more than set the read-only attribute — so a key kept on the Windows side can read as too open, and chmod 600 will not fix it there.

Each chmod digit, its nearest icacls righticacls
DigitLettersNearest right
7rwx(RX,W)Read, write and execute
6rw-(R,W)Read and write
5r-x(RX)Read and execute
4r--(R)Read
3-wx(W,X)Write and execute
2-w-(W)Write
1--x(X)Execute
0---—No access

A nearest fit, not an equivalent: Windows keeps a list of entries, each naming who gets which rights. No digit is Modify (M), which also allows deleting, or Full control (F), which also allows changing permissions (WDAC) and taking ownership (WO). On both systems the owner may always change a file's permissions.

In WSL
  • /homeOn the Linux filesystem: chmod works as on any Linux.
  • /mnt/cOn /mnt/c without the metadata option: the modes come from the Windows rights, and chmod changes almost nothing.
  • /mnt/c · metadataWith metadata: chmod works, but never past what Windows allows you.

How to check a file's permissions

ls -l shows them as letters and stat shows them as a number. Paste either into the calculator and it reads the mode back.

ls -l file prints -rw-r--r-- 1 you staff 4096 25 Oct 09:26 file, and the calculator takes the whole line — you do not have to pick the mode out of it. stat -c '%a %n' file prints 644 file on Linux; on macOS the same thing is stat -f '%Lp %N' file. For a whole directory at once, GNU find . -maxdepth 1 -printf '%m %p\n' lists every mode as a number (macOS's find has no -printf).

A + at the end of the permission string means there is more than the nine bits: on Linux it is a POSIX ACL, which getfacl shows, and those extra entries are not in the mode at all. On macOS a @ means extended attributes and a + means extended security information. With GNU ls, a dot (.) means a security context, such as SELinux's. The calculator accepts all three markers and tells you the mode is only part of the story.

An ls -l line, field by fieldls -l notes.txt
-Typerw-r--r--Permissions+Marker1LinksyouOwnerstaffGroup4096Size25 Oct 09:26Changednotes.txtName
The mode as a number
  • Linux$stat -c '%a %n' notes.txt644 notes.txt
  • macOS$stat -f '%Lp %N' notes.txt644 notes.txt
The character after the mode
  • -rw-r--r--+Linux: a POSIX ACL (getfacl lists it). macOS: extended security information such as an ACL.
  • -rw-r--r--@macOS: extended attributes.
  • -rw-r--r--.GNU ls: a security context, such as SELinux's, and nothing else.
  • -rw-r--r-- Nothing more: the nine bits are the whole story.

Chmod calculator: questions and answers

What does chmod 755 mean?

It gives the owner read, write and execute, and everyone else read and execute. Written out it is rwxr-xr-x. The digits are sums: 7 is 4 + 2 + 1 and 5 is 4 + 1. Use it for directories, which need the execute bit before anyone can enter them, and for scripts and programs. Never for a file that should stay private.

What is the difference between chmod 644 and 755?

One bit per class: the execute bit. 644 is rw-r--r--, right for documents, images, configuration and source files. 755 is rwxr-xr-x, right for directories and for anything that has to run. Giving files 755 makes every one of them executable, which is why a recursive chmod -R 755 over a website is a mistake; set directories and files separately.

What does chmod 777 do, and is it safe?

It lets every account on the machine read, change and run the file. It is almost never necessary and it is a real risk on a shared or internet-facing server: anything that can write a script the server runs can take the server over. WordPress's own documentation asks for 755 or 750 and 644 or 640, and says no directory should ever be 777. When an application cannot write somewhere, change the owner or the group, not the mode.

What does chmod +x do?

It adds the execute bit so a file can be run. Note that +x with no class is not quite a+x: a clause with no class leaves the bits in your umask alone, so with the usual umask of 022 the owner, the group and others all get execute, while a stricter umask such as 077 gives it only to the owner. Write chmod a+x or chmod u+x when you want to be sure which.

What does chmod 600 mean, and why does SSH want it?

600 is rw-------: only the owner can read or change the file. OpenSSH refuses a private key any other account can read, with the message Permissions 0644 for '<path>' are too open. The check is strict — if you own the file and any group or other bit is set at all, the key is refused, so 640 fails too. Use chmod 600 on the key and chmod 700 on ~/.ssh.

What does the fourth digit in chmod mean?

It carries the three special bits: setuid 4, setgid 2 and the sticky bit 1. chmod 2775 folder sets setgid so that new files inside take the folder's group. chmod 1777 folder sets the sticky bit so people cannot delete each other's files, which is what /tmp uses. The digit is left out when none of them is set.

Why didn't chmod 755 remove the setgid bit from my folder?

Because GNU chmod keeps setuid and setgid on a directory whenever the numeric mode has fewer than five digits — 0755 included. That is deliberate and conformant: POSIX only requires the octal form to clear those bits on a regular file. Use the symbolic form chmod g-s folder, or write the leading zeros as chmod 00755 folder. This calculator writes the five-digit form automatically when that is what your change needs.

What is the difference between chmod and chown?

chmod sets what the owner, the group and everyone else may do. chown sets who the owner and the group actually are. They answer different halves of the same question, and a "permission denied" on a web server is often an ownership problem rather than a mode problem — the files belong to the wrong user, and no mode short of 777 papers over that.

Can I paste an ls -l line into this calculator?

Yes — the whole line, not just the mode. -rw-r--r-- 1 you staff 4096 25 Oct 09:26 notes.txt is read as mode 644 on a file, and drwxrwsr-x as 2775 on a directory. The ACL marker +, the security-context dot and macOS's @ are all understood. You can also paste an operator expression such as u+x or go-w and watch which bits it changes.

What does the + or @ after the permissions mean?

They say the nine bits are not the whole story. On Linux a + means the file has a POSIX ACL with entries beyond owner, group and others — getfacl shows them, and they are not part of the mode. With GNU ls, a dot means a security context, such as SELinux's. On macOS, @ means extended attributes and + means extended security information. If permissions behave oddly despite a sensible mode, look there.

Is there a chmod equivalent on Windows?

Windows uses access control lists rather than a mode, so there is no exact equivalent. icacls file /grant Users:(RX) is the nearest command, and the calculator shows the closest rights for your mode. Inside WSL, chmod works normally on the Linux filesystem, but on a Windows drive under /mnt/c it has almost no effect unless that drive was mounted with the metadata option.

What does umask 022 give me?

644 for a new file and 755 for a new directory. A new file starts at 666 and a directory at 777, and every bit set in the umask is turned off. Because a file never starts with an execute bit, no umask can make one executable — that is always a later chmod +x. Use the umask tab above to try any value and open either result in the calculator.

Missing something?Suggest a feature or a new tool