What Is chmod? Linux File Permissions 755, 644 and 777 Explained: Reading ls -l, umask and Examples
Updated: November 6, 2026 · AracMerkezi
On Linux and Unix systems (including macOS and most web servers), every file and folder has permissions that decide who can do what. The chmod command changes these permissions. Permissions are mostly written as three-digit numbers such as 755 or 644. In this guide we explain where the numbers come from, how to read the letter string in ls -l output, the umask value that sets the default permission of new files, and the special bits. We ran all the commands below in a temporary folder and verified their output with stat.
Three user classes, three permission types
- Owner (user, u): The owner of the file.
- Group (group, g): The group the file belongs to.
- Others (others, o): Everyone else.
| Permission | Symbol | Value | On a file | On a folder |
|---|---|---|---|---|
| Read | r | 4 | Reads the content | Lists what is inside |
| Write | w | 2 | Changes the content | Adds and deletes files inside |
| Execute | x | 1 | Runs it as a program | Enters it (cd) |
A digit is the sum of the permission values of that class. 7 = 4 + 2 + 1 (rwx), 6 = 4 + 2 (rw-), 5 = 4 + 1 (r-x), 4 = r--, 0 = ---. Without x on a folder you cannot enter it; that is why folders generally use values with x, such as 755.
Reading ls -l output
An ls -l line starts with ten characters like -rwxr-xr--. The first character is the type (- file, d folder), and the next nine characters, in groups of three, are the permissions of the owner, the group and others.
Example 1: -rwxr-xr--
- Owner: rwx → 4 + 2 + 1 = 7
- Group: r-x → 4 + 0 + 1 = 5
- Others: r-- → 4 + 0 + 0 = 4
- The numeric equivalent is 754. A file created with
chmod 754really does show up inlsas-rwxr-xr--.
Example 2 (the reverse): 640 is requested. 6 = rw-, 4 = r--, 0 = ---; symbol form: rw-r-----. The owner reads and writes, the group only reads, and others can do nothing.
Common permissions
| Number | Symbol | Use |
|---|---|---|
| 755 | rwxr-xr-x | Folders and executable files |
| 644 | rw-r--r-- | Website files, plain text |
| 640 | rw-r----- | A file shared with the group, closed to everyone else |
| 600 | rw------- | Private keys (e.g. SSH) |
| 700 | rwx------ | A folder only the owner will access |
| 777 | rwxrwxrwx | Full access for everyone (avoid) |
Example 3: Fixing a site folder accidentally set to 777
Say everything in a website folder (site) was opened with chmod -R 777. The right fix is to give folders and files permissions separately:
find site -type d -exec chmod 755 {} +makes all folders 755.find site -type f -exec chmod 644 {} +makes all files 644.
We ran these two commands on a test folder that had been opened with 777: site and site/css came out 755, and site/index.html and site/css/s.css came out 644. Doing chmod -R 755 in one command makes files executable for no reason; two commands preserve the distinction. If you have executable scripts, mark them afterward one by one with chmod +x.
Symbolic mode: letters instead of numbers
chmod does not only take numbers; it also uses u, g, o, a (all) with the +, -, = operations. This makes it easy to change one thing while keeping the existing permissions.
chmod a+x script.sh: turns a 644 file into 755 (adds execute for everyone).chmod go-rwx key.pem: turns a 755 file into 700 (takes everything away from group and others).chmod u+x,g-w,o-r file: turns a 644 file into 740 (rwxr-----).
umask: why are new files 644?
The permission of a newly created file is set by the umask mask. Files start from 666 and folders from 777, and the bits in the mask are removed. The values verified by experiment:
| umask | New file | New folder |
|---|---|---|
| 022 | 644 | 755 |
| 077 | 600 | 700 |
| 002 | 664 | 775 |
022 is the default on most distributions, which is why you see "new file 644, folder 755". If you work with a shared group, 002 lets the group write.
Special bits: the fourth digit
In addition to the three digits, a leading digit carries the special bits: 4 = setuid, 2 = setgid, 1 = sticky. chmod 4755 program makes the file rwsr-xr-x (whoever runs it runs with the owner's privileges); chmod 2755 makes the group s; and chmod 1777 gives rwxrwxrwt, which in shared directories (like /tmp) lets everyone write while preventing deleting someone else's file. These bits are sensitive for security; do not set them without knowing why they are needed.
Common mistakes
- Typing chmod -R 777 folder: It opens everything to everyone. The fix is a targeted 755 or 644.
- Setting files and folders to the same permission recursively:
chmod -R 644removes x from folders and makes them impossible to enter. - A missing digit in the number: The command
chmod 7 xmakes it 007, meaning only "others" get permission; the owner can be locked out of their own file. Know that it fills in from the right and write three digits. - Leaving a private key at 644: Tools like SSH may reject a key that is too open; use 600.
- Not accounting for ownership (chown): Even if the permission number is right, an access problem persists if the file's owner is different.
Security tips
- Avoid 777. Files everyone can write to are open to malicious modification.
- Set secret keys and configuration files to 600.
- Give only the permission that is needed (the principle of least privilege).
- Before a bulk change, save the
ls -loutput to a file; if you make a mistake, you can see the old permissions and go back easily. - Keep configuration files that contain passwords outside the web root and limit them to 600 or 640.
- On shared hosting, 644 for files and 755 for folders is generally enough; check your server's documentation.
Mini glossary
- Mode: The full set of permission bits of a file.
- umask: The mask that determines which permissions are removed from new files.
- setuid / setgid: Special bits that run a program with the privileges of its owner or group.
- sticky bit: In a shared directory, lets only the owner delete their own file.
To convert a number to rwx or rwx to a number, use the Chmod Calculator. To see it at the binary level, you can look at the Number Base Converter and the guide Binary, Decimal and Hexadecimal Number Systems.
Frequently asked questions
What does 755 mean?
The owner can read, write and execute; the group and others can read and execute (rwxr-xr-x).
Which permission is suitable for website files?
Generally 644 for files and 755 for folders; also check your hosting provider's documentation.
Why is 777 not recommended?
It gives write permission to everyone, which creates a security risk; the narrowest permission needed (644, 755, 600) should be given instead.
Tools mentioned in this guide
More guides
- What Are an IP Address, CIDR and a Subnet Mask? How Many Addresses Is /24? A Calculation Method – How do you calculate CIDR notation and subnet masks? The block-size method, network and broadcast addresses, splitting into subnets and private ranges.
- What Are HTTP Status Codes? 200, 301, 404, 500 and Troubleshooting – What do HTTP status codes mean? Codes 200, 301, 404, 500, testing with curl, the cost of redirect chains, soft 404s and site-migration examples.
- What Is Regex (a Regular Expression)? A Beginner's Guide with Tested Examples and Common Mistakes – What is regex, and what do \d \w + * [] () mean? Date, phone and email examples, greedy matching, the Turkish letter issue and a ReDoS warning.
- What Is curl? Basic Flags and Converting a curl Command to fetch – What is curl and what do the -X, -H and -d flags do? A POST request example, the JavaScript fetch equivalent of a curl command, and debugging tips.
- What Is Base32? Base32 vs Base64, Step-by-Step Encoding and TOTP Keys – How does Base32 work? Encode 'foo' to MZXW6=== bit by bit, compare sizes with Base64 and hex, and see why two-factor secrets are shown in Base32.
This article is for general information only and is not legal, financial or medical advice. We are not an official institution.