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.
Type 755, paste rwxr-xr-x or a whole ls -l line, or change the mode with u+x or go-w.
| Read4 | Write2 | Execute1 | Digit | |
|---|---|---|---|---|
| Owner | 4+2+1=7 | |||
| Group | 4+1=5 | |||
| Everyone else | 4+1=5 | |||
| Special | nothing=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.
chmod 755 script.shchmod 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.
Tick 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.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.
ls -l prints firstls -l notes.txt-Typea filerw-Owner4 + 26r--Group44r--Everyone else44| Permission | On a file | On a directory |
|---|---|---|
| r4 | Read what is in it | List the names in it |
| w2 | Change what is in it | Create, rename and delete entries |
| x1 | Run it as a program | Go 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.
chmod 755rwxOwnerr-xGroupr-xEveryone else- Directories people need to go into
- Scripts and programs
- 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.
644 · 755| Read | Write | Execute | ||
|---|---|---|---|---|
| Owner | r | w | - | 6 |
| Group | r | - | - | 4 |
| Others | r | - | - | 4 |
Files: HTML, CSS, images, configuration, source code
| Read | Write | Execute | ||
|---|---|---|---|---|
| Owner | r | w | x | 7 |
| Group | r | - | x | 5 |
| Others | r | - | x | 5 |
Directories, scripts and programs
755A file at 755 can be run, and so can every image and.phpfile under achmod -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.
chmod 777| Read | Write | Execute | ||
|---|---|---|---|---|
| Owner | r | w | x | 7 |
| Group | r | w | x | 7 |
| Others | r | w | x | 7 |
- 1Any account, or any process running as one
- 2replaces the script
- 3and the web server runs it
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.
$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.
~/.ssh/700drwx------The directoryid_ed25519600-rw-------Your private keyid_ed25519.pub644-rw-r--r--The public key: anyone may read itconfig600-rw-------Not writable by others
644rw-r--r--Refused640rw-r-----Refused600rw-------Used400r--------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.
chmod u+x script.shuthe ownergthe groupoeveryone elseaall three
+add-take away=set to exactly
rreadwwritexexecuteXexecute, only on directories and on files that can already runssetuid or setgidtsticky
| Change | Before | After | |
|---|---|---|---|
u+x | 644 | 744 | Execute for the owner, nothing else touched. |
go-w | 775 | 755 | Write taken from the group and everyone else. |
a=r | 755 | 444 | All three set to read, and nothing else. |
u=rw,go=r | 777 | 644 | Three clauses: another way to write 644. |
+rwx | 644 | 755 | No class: the bits in the umask (022) are not set, so the group and everyone else get no write. |
a+rwx | 644 | 777 | With a, the umask does not count: everything is set. |
a+Xon a directory | 644 | 755 | Capital X on a directory: execute added, because it is one. |
a+Xon a file | 644 | 644 | 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.
root root /usr/bin/passwdpasswd 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.
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.
root wheel /private/tmpEveryone 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 → Clear it with five digits or with the letters:$chmod 00755 project → $chmod g-s project → 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.
umask 022| Starts at | rw-rw-rw- | 666 |
|---|---|---|
| umask | ····w··w· | 022 |
| Gets | rw-r--r-- | 644 |
| Starts at | rwxrwxrwx | 777 |
|---|---|---|
| umask | ····w··w· | 022 |
| Gets | rwxr-xr-x | 755 |
| umask | New file | New directory |
|---|---|---|
022 | 644 | 755 |
002 | 664 | 775 |
027 | 640 | 750 |
077 | 600 | 700 |
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.
| The folder | Now | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
site/ | 755 | 755 | 644 | 755 | 755 |
index.html | 644 | 755 | 644 | 644 | 644 |
app.php | 644 | 755 | 644 | 644 | 644 |
deploy.sh | 755 | 755 | 644 | 644 | 755 |
img/ | 755 | 755 | 644 | 755 | 755 |
logo.png | 644 | 755 | 644 | 644 | 644 |
- 1
$chmod -R 755 siteEvery file can be run - 2
$chmod -R 644 siteNo folder can be entered - 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
$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.
icacls| Digit | Letters | Nearest right |
|---|---|---|
| 7 | rwx | (RX,W)Read, write and execute |
| 6 | rw- | (R,W)Read and write |
| 5 | r-x | (RX)Read and execute |
| 4 | r-- | (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.
/homeOn the Linux filesystem:chmodworks as on any Linux./mnt/cOn/mnt/cwithout themetadataoption: the modes come from the Windows rights, andchmodchanges almost nothing./mnt/c · metadataWithmetadata:chmodworks, 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.
ls -l line, field by fieldls -l notes.txt-TypePermissions+Marker1LinksyouOwnerstaffGroup4096Size25 Oct 09:26Changednotes.txtName- Linux
$stat -c '%a %n' notes.txt644 notes.txt - macOS
$stat -f '%Lp %N' notes.txt644 notes.txt
-rw-r--r--+Linux: a POSIX ACL (getfacllists it). macOS: extended security information such as an ACL.-rw-r--r--@macOS: extended attributes.-rw-r--r--.GNUls: 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?
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?
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?
What does chmod +x do?
+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?
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?
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?
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?
-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?
+ 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?
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?
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
Related tools
Password Generator
Strong random passwords, passphrases and PINs made in your browser, each with its exact bits and crack time
UUID Generator
Generate UUID v4, v7, v1, v5 and v3 or GUIDs in bulk, in any format, and decode a UUID's version and timestamp
Binary Translator
Translate text to binary and binary to text: auto-detect, hex, decimal and octal
Base64 Decode & Encode
Decode and encode Base64: text (UTF-8, URL-safe), images, PDFs and any file to Base64 or a data URI
Epoch Converter
Convert Unix timestamps to dates and dates to epoch time in any time zone, with batch conversion
CSR & Certificate Decoder
Decode a CSR or SSL certificate: subject, SANs, key size, validity, issuer, fingerprint, signature check and CSR-to-certificate match