# How to understand chmod permissions (644, 755 and more)

> Read rwx permissions and octal modes, choose between 644 and 755, understand setuid, setgid and the sticky bit, and see why chmod 777 is rarely the fix.

- URL: https://www.tooljig.com/blog/how-to-understand-chmod-permissions
- Category: Developer
- Published: 2026-11-23

Every file and directory on Linux, macOS and other Unix-like systems has a mode that says who can read, change and run it. You see it as `-rwxr-xr-x` in `ls -l` and set it with `chmod 755`. Both notations encode the same nine bits plus three special ones, and once you can translate between them you can fix most "Permission denied" errors without guessing.

> Tool: [Chmod Calculator](https://www.tooljig.com/chmod-calculator): Work out Unix file permissions with checkboxes, convert between octal (755, 4755) and symbolic (rwxr-xr-x) modes, and copy the chmod command.

## Step by step

1. Open the [chmod calculator](https://www.tooljig.com/chmod-calculator).
2. Tick **Read**, **Write** and **Execute** for **Owner**, **Group** and **Others**. Alternatively, type an octal mode such as `644` or `4755` in **Octal**, or a symbolic mode as `ls -l` prints it, such as `rwxr-xr-x`, in **Symbolic**. The other fields update to match.
3. Tick **Setuid (4000)**, **Setgid (2000)** or **Sticky (1000)** if you need a special bit.
4. Read the summary of who can read, write and execute.
5. Enter your file name and copy the command. You get a numeric form such as `chmod 755 deploy.sh` and a symbolic form such as `chmod u=rwx,g=rx,o=rx deploy.sh`.

## Read, write and execute, for three classes of user

Permissions are granted to three classes:

- **Owner** (`u`): the user who owns the file.
- **Group** (`g`): members of the file's group.
- **Others** (`o`): everyone else.

Each class gets three permissions. What they mean depends on whether the target is a file or a directory:

| Permission | On a file | On a directory |
| --- | --- | --- |
| `r` read | Read the contents | List the names of entries |
| `w` write | Change the contents | Create, delete and rename entries (needs `x` too) |
| `x` execute | Run it as a program | Enter it and access entries by name |

This explains two surprises: deleting a file depends on write permission on its directory, not on the file, and a directory with `r` but not `x` shows names you cannot open. Directories almost always have `x` wherever they have `r`.

In `ls -l` output the first character is the file type (`-` for a regular file, `d` for a directory, `l` for a symbolic link), followed by three groups of three:

```text
-rw-r--r--  1 ada  staff  1204 Nov 23 09:14 notes.txt
drwxr-xr-x  5 ada  staff   160 Nov 23 09:10 project
```

## Octal notation

Each permission has a value: read is 4, write is 2 and execute is 1. Add them for each class and you get one digit per class, in the order owner, group, others.

| Digit | Permissions | Symbolic |
| --- | --- | --- |
| 7 | read, write, execute | `rwx` |
| 6 | read, write | `rw-` |
| 5 | read, execute | `r-x` |
| 4 | read | `r--` |
| 0 | none | `---` |

So `754` is `rwx` for the owner, `r-x` for the group and `r--` for others.

The modes you will use most:

| Mode | Symbolic | Typical use |
| --- | --- | --- |
| 644 | `rw-r--r--` | Ordinary files: web pages, configuration, documents |
| 755 | `rwxr-xr-x` | Programs, scripts and directories |
| 600 | `rw-------` | Private files: SSH private keys, files containing secrets |
| 700 | `rwx------` | Private directories, such as `~/.ssh` |
| 640 | `rw-r-----` | Files a service group needs to read, such as logs |
| 775 | `rwxrwxr-x` | Shared directories where a team group writes |

### 644 versus 755

The only difference is the execute bit. Use 644 for files that are read but never run, and 755 for programs and for directories, which need `x` to be entered. A shell script that fails with "Permission denied" when you run `./deploy.sh` usually just needs `chmod 755 deploy.sh`, or `chmod u+x deploy.sh` to add execute for the owner alone.

New files are filtered by the umask: the common `022` removes write for group and others, so new files usually get 644 and directories 755.

## Symbolic mode changes

Symbolic modes change specific bits and keep the rest, which is safer than an octal mode when you want to change one thing:

```bash
chmod u+x script.sh         # add execute for the owner
chmod g-w report.csv        # remove write for the group
chmod o= secrets.env        # remove all permissions for others
chmod a+r index.html        # add read for everyone (a = all)
chmod u=rw,go=r notes.txt   # set exactly 644
```

> **Warning:** `chmod -R 755 directory` makes every file inside executable, which is wrong for ordinary files. Set directories and files separately: `find directory -type d -exec chmod 755 {} +` and `find directory -type f -exec chmod 644 {} +`.

## Setuid, setgid and the sticky bit

A fourth, leading octal digit holds three special bits:

- **Setuid (4)**: an executable runs with the privileges of the file's owner instead of the user who started it. `/usr/bin/passwd` uses this to update the password database. Shown as `s` in the owner's execute position: `rwsr-xr-x` is 4755.
- **Setgid (2)**: an executable runs with the file's group. On a directory, new files created inside inherit the directory's group, which is useful for shared project folders. Shown as `s` in the group's execute position: `rwxrwsr-x` is 2775.
- **Sticky (1)**: on a directory, only a file's owner, the directory's owner or root can delete or rename files in it, even if others have write permission. `/tmp` is the classic example at 1777, shown as `rwxrwxrwt`.

A capital letter means the special bit is set without the matching execute bit: `rwSr--r--` is 4644, a setuid bit with no effect, and usually a mistake.

Setuid programs are a common target for privilege escalation, so avoid setting it unless you know exactly why. Linux ignores setuid on `#!` scripts.

Note that GNU chmod keeps a directory's setuid and setgid bits when given a mode like 755; clear them explicitly with `chmod g-s directory`.

## Why chmod 777 is risky

`777` gives every user on the system read, write and execute permission. Anyone, including a compromised service account such as a web server process, can change or replace the file, so a script can be made to run someone else's code the next time you execute it.

777 seems to fix "Permission denied" because it removes every check. A web server answering [403 Forbidden](https://www.tooljig.com/http-status-codes) for a file it cannot read is a typical case. The real fix is almost always one of these:

1. Change the owner or group with `chown` so the right user or service owns the file.
2. Add only the missing permission, such as `g+w` for a group that needs to write.
3. For shared directories, use a group with setgid (2775).

Before applying a mode from a deployment script, paste it into the calculator and read the summary. The [number base converter](https://www.tooljig.com/number-base-converter) shows how an octal mode maps to binary bits, and [how to calculate a subnet](https://www.tooljig.com/blog/how-to-calculate-a-subnet) covers the networks those servers sit on.

## FAQ

### What does chmod 755 mean?

The owner can read, write and execute (7), and the group and everyone else can read and execute (5). It is the usual mode for programs, scripts and directories.

### What is the difference between 644 and 755?

644 (`rw-r--r--`) lets only the owner write and nobody execute, which suits ordinary files. 755 (`rwxr-xr-x`) adds execute for everyone, which programs and directories need.

### Why can I delete a file I have no write permission on?

Deleting a file is a change to the directory, not the file. If you have write and execute permission on the directory, you can remove entries in it, unless the directory has the sticky bit set and you do not own the file.
