What is chmod?
chmod (short for “change mode”) is a core Unix and Linux command used to change the access permissions of files and directories. Every file on a Unix-like system has three sets of permissions controlling access for the file’s owner, its group, and all other users.
Permissions were part of the original Unix design in the 1970s and remain the cornerstone of file security on Linux, macOS, BSD, and every other Unix-like operating system. Understanding chmod matters for system administration, web development, deployment, and security. This calculator converts between the two ways of writing permissions — numeric (octal) like 755 and symbolic like rwxr-xr-x — so you never have to do the math by hand.
Permission Types
Each file has three types of access:
- Read (r = 4): View file contents or list directory contents
- Write (w = 2): Modify or delete the file, or add/remove files in a directory
- Execute (x = 1): Run the file as a program, or enter (
cdinto) a directory
These are assigned independently to three categories of users:
- Owner (u): The user who owns the file
- Group (g): Users in the file’s group
- Others (o): Everyone else
Numeric (Octal) Notation
The numeric system uses three digits, one per category. Each digit is the sum of permission values:
| Permission | Value |
|---|---|
| Read (r) | 4 |
| Write (w) | 2 |
| Execute (x) | 1 |
| None (-) | 0 |
For example, chmod 755 means:
- Owner: 7 (4+2+1) = rwx (read, write, execute)
- Group: 5 (4+0+1) = r-x (read, execute)
- Others: 5 (4+0+1) = r-x (read, execute)
Because each digit is a sum of 4, 2, and 1, every digit from 0 to 7 maps to exactly one combination of rwx — that is why octal notation is so compact.
How to Read ls -l Output
When you run ls -l, each line begins with a 10-character permission string such as -rwxr-xr-x. Reading it left to right:
- rwx r-x r-x
│ │ │ └── others (r-x = 5)
│ │ └─────── group (r-x = 5)
│ └──────────── owner (rwx = 7)
└──────────────── file type
The first character is the file type, not a permission:
-regular fileddirectorylsymbolic linkc/bcharacter or block devicessocket,pnamed pipe
So -rwxr-xr-x is a regular file with mode 755, and drwxr-xr-x is a directory with the same permissions.
How to Use This Tool
- Click the checkboxes to toggle read, write, and execute for each category
- Or enter a numeric value (like 755) to see the visual breakdown
- Read the numeric code and symbolic representation
- Copy the ready-to-run
chmodcommand
Common Permission Values
| Numeric | Symbolic | Typical Use |
|---|---|---|
| 777 | rwxrwxrwx | Full access for everyone (dangerous) |
| 755 | rwxr-xr-x | Executable files, directories, scripts |
| 750 | rwxr-x— | Group-restricted executables |
| 644 | rw-r–r– | Regular files (web content) |
| 640 | rw-r—– | Group-readable config files |
| 600 | rw——- | Private files (SSH keys, configs) |
| 400 | r——– | Read-only private files |
chmod 755 vs 644 vs 777
These three are by far the most common values, and choosing between them trips up a lot of developers:
- 755 (
rwxr-xr-x) — use for directories and executable files (shell scripts, binaries, CGI). Everyone can read and traverse, but only the owner can change the contents. Directories almost always need the execute bit, otherwise no one cancdinto them. - 644 (
rw-r--r--) — use for regular, non-executable files: HTML, CSS, JavaScript, images,.txt, and most uploads. The owner edits, everyone else reads. Giving these files755needlessly marks them executable. - 777 (
rwxrwxrwx) — avoid in almost all cases. A “quick fix” ofchmod 777to make an upload folder work usually just hides a real ownership problem and leaves the path world-writable. Prefer fixing the owner/group withchownand using755/775.
Special Permissions: setuid, setgid, and the Sticky Bit
Beyond the three standard digits, Unix supports a fourth, leading octal digit for special behavior:
| Bit | Octal | Symbol | Effect |
|---|---|---|---|
| setuid | 4000 | s (owner x) | Runs the file with the owner’s privileges |
| setgid | 2000 | s (group x) | Runs with the group’s privileges; on a directory, new files inherit its group |
| sticky | 1000 | t (others x) | On a directory, only a file’s owner can delete or rename it |
Examples you will actually encounter:
chmod 4755 program # rwsr-xr-x — setuid (like /usr/bin/passwd)
chmod 2755 shared/ # rwxr-sr-x — setgid directory, group is inherited
chmod 1777 /tmp # rwxrwxrwt — world-writable but sticky
The lowercase s/t appears when the underlying execute bit is set; an uppercase S/T means the special bit is on but execute is not — usually a mistake.
Symbolic Notation
Symbolic notation changes specific bits without recomputing the whole mode. It uses who (u, g, o, a), an operator (+ add, - remove, = set exactly), and the permissions:
chmod u+x file # Add execute for owner
chmod g-w file # Remove write for group
chmod o=r file # Set others to read-only
chmod a+r file # Add read for all (a = all)
chmod u=rwx,g=rx,o=r file # Set every class at once (equals 754)
Symbolic mode is ideal when you want to say “just make this executable” (chmod +x script.sh) without caring about the rest of the bits.
Recursive chmod (and the -R 777 Trap)
The -R flag applies a mode to a directory and everything inside it:
chmod -R 755 mysite/
The classic mistake is chmod -R 777 on a web root to “fix permissions.” It makes every file and directory world-writable and executable, which is both a security hole and often still doesn’t solve the original problem. When directories and files need different modes, split them:
find . -type d -exec chmod 755 {} \; # directories: traversable
find . -type f -exec chmod 644 {} \; # files: read-only for others
This gives directories their required execute bit while keeping regular files non-executable.
Common chmod Errors and Fixes
Operation not permitted— you don’t own the file. Only the owner (or root) can change a file’s mode. Usesudo, or fix ownership first withchown.Permission deniedwhen running a script — the execute bit is missing. Runchmod +x script.sh, then./script.sh.chmod: cannot access 'file': No such file or directory— the path is wrong or the file was moved. Check withls -l.- Changes have no effect — the file is on a filesystem that doesn’t store Unix permissions (FAT32, exFAT, NTFS USB drives, Windows paths under WSL
/mnt, or many FTP/SMB shares). chmod silently does nothing there. - Still denied after
chmod 777— a parent directory likely lacks the execute bit (you needxon every directory in the path), or a security layer such as SELinux or AppArmor is blocking access. Widening permissions won’t help.
chmod vs chown
They are often confused. chmod changes what can be done (read/write/execute); chown changes who owns the file (user and group). If a web server can’t write to an upload folder, the real fix is usually chown to the correct service user plus a sane 775/644 — not chmod 777.
Best Practices
- Principle of least privilege: Grant only the permissions that are needed
- Never use 777: Full access for everyone is a security risk — fix ownership instead
- Directories need execute: Without
x, users can’tcdinto or list a directory - Use 600 for sensitive files: SSH keys, database credentials, and config files with secrets
- Set directory permissions to 755 and files to 644: the standard, safe web defaults
- Check before changing: Use
ls -lato view current permissions before modifying - Use groups wisely: Instead of opening permissions to “others”, add users to the file’s group