What Permissions 755 and 644 Mean and How to Read Them: Turning rwxr-xr-x Into a Number, How Files and Directories Differ, and Which Number to Use for What
Server setup guides often say “set files to 644 and directories to 755”, and ls -l prints rows of -rw-r--r-- and drwxr-xr-x, yet it is surprisingly hard to explain what those numbers and letters actually allow. This guide shows, with worked examples, how a permission number is just r = 4, w = 2 and x = 1 added together, how to read the 10 characters in ls -l, why the same r, w and x mean different things for files and directories, when to use common numbers such as 600, 700, 775, 1777 and 4755, and how chmod +x and the umask change the number.
The short answer: the 3 digits are owner, group and others, and each digit is r = 4 + w = 2 + x = 1
Files on Linux, macOS and other Unix-like systems carry permissions that decide who can do what. “Who” is one of three classes, the owner (u), the group (g) and others (o), and “what” is one of three actions, read (r), write (w) and execute (x). Numbers such as 755 and 644 pack these 3 × 3 = 9 on/off switches into 3 digits.
Each digit is the sum of what is allowed, counting r as 4, w as 2 and x as 1. The digits are, from left to right, the owner, the group and others, so 755 means owner 7 (rwx), group 5 (r-x) and others 5 (r-x), which is rwxr-xr-x, and 644 means owner 6 (rw-), group 4 (r--) and others 4 (r--), which is rw-r--r--.
The same x means “can run it as a program” for a file but “can enter it” for a directory, though. And a 4th leading digit (the first digit of 4755 or 1777) holds special settings called setuid, setgid and the sticky bit. We go through each of these below.
How the number is built: add up r, w and x to get one digit
r = 4, w = 2 and x = 1 are the three bits of a binary number (100, 010 and 001), so no two combinations ever add up to the same value. The 8 digits from 0 to 7 map one-to-one onto rwx like this.
| Digit | rwx | Sum | What it allows |
|---|---|---|---|
| 0 | --- | 0 | Nothing |
| 1 | --x | 1 | Execute only |
| 2 | -w- | 2 | Write only (hardly ever used alone) |
| 3 | -wx | 2 + 1 | Write and execute (hardly ever used) |
| 4 | r-- | 4 | Read only |
| 5 | r-x | 4 + 1 | Read and execute |
| 6 | rw- | 4 + 2 | Read and write |
| 7 | rwx | 4 + 2 + 1 | Everything |
In practice you mostly see 0, 4, 5, 6 and 7, with 1 (x only, on a directory) turning up now and then. 2 and 3 mean “can write but cannot read”, which is almost never what you want.
- 1
Split rwxr-xr-x into groups of 3
You get rwx / r-x / r-x. From left to right these are the owner, the group and others.
- 2
Add r = 4, w = 2 and x = 1 in each group
rwx = 4 + 2 + 1 = 7, r-x = 4 + 1 = 5 and r-x = 5. A - counts as 0.
- 3
Write the three digits side by side
7, 5 and 5 give 755. In the same way rw-r--r-- is 6, 4, 4 = 644, rw------- is 6, 0, 0 = 600 and rwxr-x--- is 7, 5, 0 = 750.
To go from a number back to rwx, split each digit into 4, 2 and 1: 6 is 4 + 2, so rw-, and 5 is 4 + 1, so r-x. The number is octal, so it is sometimes written with a leading 0, as in 0755 or 0644, but that means exactly the same as 755 and 644.
Reading the 10 characters in ls -l: the first character is not part of the number
Running ls -l prints 10 characters such as -rw-r--r-- or drwxr-xr-x at the start of each line. Only the last 9 are the permissions; the first character is the file type. To get the number, drop the first character and read the remaining 9 in groups of 3.
| Shown by ls -l | Type | Number | Meaning |
|---|---|---|---|
| -rw-r--r-- | Regular file (-) | 644 | Owner reads and writes, everyone else only reads |
| -rwxr-xr-x | Regular file (-) | 755 | Owner can do everything, everyone else reads and executes |
| -rw------- | Regular file (-) | 600 | Only the owner reads and writes |
| drwxr-xr-x | Directory (d) | 755 | Owner can do everything, everyone else can list and enter |
| drwxr-x--- | Directory (d) | 750 | Others cannot enter |
| drwxrwxrwt | Directory (d) | 1777 | Like /tmp: everyone can write, but nobody can delete other people's files |
| -rwsr-xr-x | Regular file (-) | 4755 | Executable with setuid (such as passwd) |
- A leading l is a symbolic link. It shows as lrwxrwxrwx, but the link's own permissions are hardly ever used; access is decided by the permissions of the file it points to
- A trailing ., + or @ can appear (as in -rw-r--r--@). . marks an SELinux context, + an ACL (extra access rules) and @ macOS extended attributes. None of them are part of the number
- An s or t in an x position is a special bit. Lowercase s or t means x is also set; uppercase S or T means x is not set (see below)
On a directory, r, w and x mean something different
A directory is essentially a box holding a list of file names, so r, w and x mean something different from what they mean on a file. Mixing these up leads to puzzles like “I set the directory to 644 and now I can't get into it” or “the file is 444 but it still got deleted”.
| Permission | On a file | On a directory |
|---|---|---|
| r (4) | Can read the contents | Can list the files inside (ls) |
| w (2) | Can change the contents | Can create, delete and rename files inside |
| x (1) | Can run it as a program | Can enter it (cd) and open files inside |
Whether a file can be deleted depends on the w of the directory it is in, not on the file's own w. A 444 file (read-only for everyone) can still be deleted if the directory has w. So to protect a file from being changed, you need to look at both the file's and the directory's permissions.
- A directory with r but no x (such as 644 or 600): you can see the list, but you cannot enter it or open the files inside. Directories normally get r and x together
- A directory with x but no r (such as the group and others of 711): files whose names you know can be opened, but ls cannot list them. This is used to hide what is in a home directory while still letting people use specific files
- Even if a directory is 755, other people cannot read a 600 file inside it. Conversely, a 644 file is unreadable if any directory on the way to it lacks x, because nobody can get there
Quick table by use: when to choose 600, 700, 640, 750, 775, 664 and others
Here are the numbers you meet most often, with their rwx and typical uses. If in doubt, start from what other people need to do and add only that much.
| Number | rwx | Typical use |
|---|---|---|
| 755 | rwxr-xr-x | Standard for directories, executables, shell scripts and CGI |
| 644 | rw-r--r-- | Standard for ordinary files (HTML, CSS, images, config files) |
| 600 | rw------- | Only you can read and write. SSH private keys, .env and files containing passwords |
| 700 | rwx------ | Directories only you can use (~/.ssh) and your own private scripts |
| 400 | r-------- | Only you can read it, and it cannot be changed. AWS .pem keys |
| 640 | rw-r----- | Owner reads and writes, group only reads. Logs and config files shared with a group |
| 750 | rwxr-x--- | Directories only the owner and group can enter, and scripts only they can run |
| 775 | rwxrwxr-x | Directories a group works on together |
| 664 | rw-rw-r-- | Files a group edits together |
| 660 | rw-rw---- | Files only the owner and group can read and write |
| 770 | rwxrwx--- | Directories for the owner and group only |
| 711 | rwx--x--x | Directories others can enter but not list (such as home directories) |
| 444 | r--r--r-- | Read-only for everyone. Files you don't want changed by accident |
| 666 | rw-rw-rw- | Anyone can read and write. Not normally used |
| 777 | rwxrwxrwx | Anyone can do anything. Only for testing |
It is easiest to remember them as file/directory pairs: 644/755 for things that may be public, 640/750 for things shared only with a group, 664/775 for things a group edits together, and 600/700 for things that are yours alone. Each file number is the directory number with x (the 1 in each digit) taken out.
4-digit numbers: setuid (4000), setgid (2000) and the sticky bit (1000)
When a permission is written with 4 digits, as in 4755 or 1777, the first digit holds the special bits. It is a sum as well: setuid = 4, setgid = 2 and the sticky bit = 1. In ls -l they appear as s, s and t in the x positions of the owner, group and others.
| Number | Shown by ls -l | Meaning and example |
|---|---|---|
| 4755 | -rwsr-xr-x | setuid. Runs with the owner's privileges (such as root) rather than those of the person running it. The passwd command, for example |
| 2755 | drwxr-sr-x | Directory with setgid. Files created inside it take the directory's group |
| 2775 | drwxrwsr-x | Shared folder with setgid. Used for directories a group works on together |
| 1777 | drwxrwxrwt | Sticky bit. Like /tmp, everyone can write, but nobody can delete other people's files |
| 4644 | -rwSr--r-- | setuid without x. Shown as a capital S and usually a mistake |
A lowercase s or t means “special bit plus x”, and an uppercase S or T means “special bit only, no x”. So rwsr-xr-x is 4755 and rwSr--r-- is 4644. Without special bits, the leading 0 is normally left off and the number written with 3 digits; 0755 and 755 mean the same.
- If setuid is set on a file owned by root, whoever runs it temporarily gets root's privileges. Set it only where it is really needed; most systems ignore it on shell scripts
- The sticky bit makes a directory that everyone can write to safe to share: only the file's owner, the directory's owner and root can delete or rename a file. On an ordinary file it means nothing on current Linux
- setgid can also be set on files, which then run with the group's privileges. In practice you mostly see it on shared directories as 2775 or 2770
Writing chmod: set the whole number, or add and remove with symbols
chmod is the command that changes permissions. There are two ways to write it: set the whole thing with a number, as in chmod 755 file, or add and remove part of it with symbols, as in chmod u+x file. The number 755 written with symbols is chmod u=rwx,g=rx,o=rx file.
| Symbol | Meaning |
|---|---|
| u, g, o, a | Owner, group, others, all |
| + | Add this permission (leave the rest) |
| - | Remove this permission (leave the rest) |
| = | Set exactly this permission (remove anything not listed) |
| X (capital) | Add x only to directories and to files that already have x somewhere |
With symbols, the result depends on the number you start from. Here are the results of common operations, worked out the same way GNU chmod does it (rows without u, g, o or a assume umask 022).
| Before | Command | After | Note |
|---|---|---|---|
| 644 | chmod +x | 755 | Everyone gets x |
| 644 | chmod u+x | 744 | Use this if only you need to run it |
| 600 | chmod +x | 711 | Even people who cannot read it get x |
| 664 | chmod +x | 775 | The group's w stays |
| 664 | chmod go-w | 644 | Removes w from the group and others |
| 777 | chmod go-w | 755 | Pulls 777 back to a safe setting |
| 755 | chmod o= | 750 | Removes all of others' permissions |
| 640 | chmod g=u | 660 | Makes the group the same as the owner |
| 644 | chmod a=r | 444 | Read-only for everyone |
| 644 (directory) | chmod a+X | 755 | Directories get x |
| 644 (file) | chmod a+X | 644 | A file without x does not get it |
| 755 | chmod u+s | 4755 | Adds setuid |
Watch out for forms that leave out u, g, o and a. chmod +x means “x for everyone”, but it does not touch bits that the umask forbids. With umask 022, chmod +x on 644 gives 755, but chmod +w leaves 644 as it is instead of making it 666 (the owner already has w). To give w to everyone, say so with a+w (the result is 666).
New files come out as 644 because of umask 022
Files you create with touch come out as 644 and directories you create with mkdir as 755 because of a setting called the umask. Programs normally ask for 666 for files and 777 for directories, and the bits set in the umask are then removed. The usual default is umask 022: removing its bits (w for the group and others) from 666 gives 644 for files, and from 777 gives 755 for directories.
| umask | New files | New directories | Where it is used |
|---|---|---|---|
| 022 | 644 (rw-r--r--) | 755 (rwxr-xr-x) | Default on most Linux and macOS systems |
| 002 | 664 (rw-rw-r--) | 775 (rwxrwxr-x) | Setups where a group works together |
| 027 | 640 (rw-r-----) | 750 (rwxr-x---) | Servers that hide files from others |
| 007 | 660 (rw-rw----) | 770 (rwxrwx---) | Shared with the group only |
| 077 | 600 (rw-------) | 700 (rwx------) | Only you |
| 000 | 666 (rw-rw-rw-) | 777 (rwxrwxrwx) | No restriction. Not normally used |
A umask removes bits rather than subtracting, so with umask 033 new files are still 644, not 633 (666 has no x to begin with). Directories lose the bits from 777 and become 744. To work backwards from the directory permission you want, the umask is whatever is left of 777 once you take out the bits you want: for 750, it is umask 027.
Settings to avoid, and common stumbling blocks
- Don't use 777: anyone can change and execute the file, so other users on the same server, or an attacker exploiting a weakness in a web app, can rewrite it. “It didn't work, so I set 777” only hides the real cause. Match the owner or group to the web server's user and check whether 755 or 775 is enough first
- Don't give others w: files and directories where others (o) have w, such as 666 or 757, can be changed by anyone on the server. For directories that really are written by everyone, like /tmp, use 1777 with the sticky bit
- SSH private keys need 600 or 400: if id_rsa, id_ed25519 or an AWS .pem is left at 644 or 640, someone other than you can read it, so ssh prints “UNPROTECTED PRIVATE KEY FILE!” and refuses to use the key. A good guide is 700 for the ~/.ssh directory and 600 for authorized_keys
- Don't give others more than the owner: permission checks pick exactly one class, in the order owner, group, others. With 460, where the owner has only r and the group has rw, people in the group can write but the owner cannot
- Scripts need r too: with x but no r (as in 711), compiled programs run, but shell scripts and Python need to read their contents, so they don't
- Be careful when the owner has no r: if you remove the owner's r, as in 200 or 300, you cannot read the contents yourself (root still can)
If things still don't work after changing permissions, check not just the number but also the owner and group (the 3rd and 4th columns of ls -l). A common cause is that the permissions are right but the owner is still root, so the web server's user falls under “others”. If a script run by cron doesn't work, there is more to check than execute permission; see the checklist for when cron doesn't run as well.
Checking numbers, rwx and umask with the chmod Calculator
The chmod Calculator lets you check everything above in your browser. Before running chmod on a server, it is reassuring to see the resulting number and who will be able to do what.
- 1
Enter a number or ls -l notation on “Number ↔ rwx”
It accepts numbers such as 755, 0644 and 4755 as well as ls -l notation such as -rw-r--r-- and drwxrwxrwt. You can also build a number by ticking and unticking boxes.
- 2
Choose File or Directory
It shows what the owner, group and others can each do, worded separately for files and directories, and warns about 777, files others can write, and settings unsuitable for private keys.
- 3
See symbolic results on “Try chmod u+x and more”
Enter the current permission and an expression such as u+x, go-w or a+X to see the result of each step. It also reproduces how the umask affects expressions that leave out u, g, o and a.
- 4
See new-file numbers on “umask calculator”
It gives the numbers for new files and directories from umask 022, 002, 027 and others, and works out the umask from the directory permission you want.
FAQ
- What is the difference between permission 755 and 644?
- With 755 (rwxr-xr-x) the owner can read, write and execute, and the group and others can read and execute. With 644 (rw-r--r--) the owner can read and write, everyone else can only read, and nobody can execute. Use 755 for directories, shell scripts and CGI, and 644 for ordinary files such as HTML, images and config files.
- What is rwxr-xr-x as a number?
- Split it into groups of 3 characters and add r = 4, w = 2 and x = 1. rwx = 7, r-x = 5 and r-x = 5, so it is 755. The first character in ls -l (- or d) is the file type and is not part of the number. rw-r--r-- is 644, rw------- is 600 and rwxrwxrwt is 1777.
- What happens if I set a directory to 644?
- On a directory, x is the permission to enter it and open files inside, so with 644 you can see the list but cannot open anything in it. Give directories r and x together: 755 if others may look, 700 or 750 if not.
- What does chmod +x turn 644 into?
- +x without u, g, o or a adds x for everyone, so with umask 022, 644 becomes 755. If only you need to run it, chmod u+x gives 744. chmod +x turns 600 into 711 and 664 into 775.
- What is the first digit of a 4-digit permission (4755, 2775, 1777)?
- It holds the special bits and is the sum of setuid = 4, setgid = 2 and the sticky bit = 1. 4755 is an executable that runs with the owner's privileges (rwsr-xr-x), 2775 is a shared folder whose new files take the directory's group (rwxrwsr-x), and 1777 is a directory like /tmp where everyone can write but nobody can delete other people's files (rwxrwxrwt).
- What permission should an SSH private key have?
- 600 or 400. If anyone else can read it, as with 644 or 640, ssh prints “UNPROTECTED PRIVATE KEY FILE!” and refuses to use the key. A good guide is 700 for the ~/.ssh directory and 600 for authorized_keys.
- Why is permission 777 dangerous?
- Anyone can change and execute the file, so other users on the same server, or an attacker exploiting a weakness in a web app, may be able to rewrite it. Even for directories that need to be writable, first check whether matching the owner or group to the web server's user lets you get by with 755 or 775.
Tools in this article
Related articles
Full Moon Calendar 2027: Dates, Times and Names | The Supermoon Is January 22, the Strawberry Moon June 18–19, and There Is No Blue Moon
“When is the next full moon?” “What date is the Strawberry Moon this year?” “When can I see the supermoon?” Full moon dates shift every year, and websites name and count supermoons a little differently, so the more you search the more confusing it gets. This article lists all 12 full moons of 2027 in Universal Time (UTC) and US Eastern time, worked out with the same formulas as the Moon Phase Calendar & Birthday Moon tool (Meeus, Astronomical Algorithms, accurate to within a minute), together with their names from the Wolf Moon to the Cold Moon and the distance to the moon. It also explains, with numbers, which full moon is the biggest and smallest of 2027, why 2027 has neither a Blue Moon nor a Corn Moon, which night to look when the exact full moon falls in daytime, and how the date changes between time zones.
Read article →Born in January or Early February? When Your Yakudoshi Falls, Counting From Risshun, and How to Find Your Nine Star Ki Birth Star and Happo-fusagari Years | In 2027 It Is 9 Purple Fire
“I heard my unlucky years shift by one because I was born in January.” “I was born on Setsubun, so which birth star am I?” “Someone told me my happo-fusagari year and my yakudoshi fall in the same year.” Japanese unlucky years (yakudoshi) and Nine Star Ki are hardest to pin down for people born between January 1 and Setsubun. This article explains how your yakudoshi changes depending on whether a shrine starts the year on New Year’s Day or at Risshun, why Risshun moves between February 3 and 5, how to work out your birth star, which birth years are in happo-fusagari from 2026 to 2029, and why women’s honyaku at 19 and 37 always coincides with happo-fusagari. Every figure was checked with the Yakudoshi Calculator.
Read article →How to Calculate Building Coverage Ratio and Floor Area Ratio in Japan | How Big a House Fits on a 30-Tsubo Plot? Worked Examples for Front Road Width, Setback and Corner Lot Relief
A Japanese land listing may say “coverage ratio 60%, floor area ratio 200%”, but that does not tell you at a glance how big a house you can build. On top of that, the floor area ratio drops when the front road is narrow, and on roads under 4 m wide a setback takes land off the site itself. This article walks through the formulas for building coverage ratio (kenpei-ritsu) and floor area ratio (yoseki-ritsu), a chart of what fits on a 30-tsubo plot, worked examples for the front road, setbacks, corner lot and fire zone relief and the specified road relief, and how much floor area two- and three-storey houses can actually reach, all with figures from the Building Coverage & Floor Area Ratio Calculator.
Read article →