The chmod command in Linux

chmod (change mode) sets who can read, write and execute a file. Linux permissions are three groups of three bits — owner, group, others — each holding read (r=4), write (w=2) and execute (x=1). The famous numbers are just sums: 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--. So 755 means "owner can do everything, everyone else can read and execute", and 644 means "owner can read and write, everyone else can only read".

How chmod works

Permissions live in the inode as a 12-bit mode: nine bits you know (read, write, execute for owner, group, other) plus three special ones — setuid, setgid and sticky. The octal notation is nothing more than those bits written in base 8, which is why 755 and rwxr-xr-x are the same fact in two spellings.

The special bits carry real machinery. Setuid on an executable makes it run with the file owner's privileges (how passwd, owned by root, edits a root-only file for you). Setgid on a directory makes new files inherit the directory's group — the backbone of shared team folders. The sticky bit on a world-writable directory (see /tmp: drwxrwxrwt) restricts deletion to each file's owner. And "execute" on a directory actually means search: permission to resolve names through it, which is why a directory without x is sealed no matter what is inside.

chmod755ownerr4w2x14+2+1 = 7groupr42x14+0+1 = 5othersr42x14+0+1 = 5r = read (4) · w = write (2) · x = execute (1)result in ls -l: rwx r-x r-x
How 755 decomposes: one octal digit per audience, each the sum of its permission bits.

Syntax

chmod [OPTIONS] MODE FILE...

Common options

OptionWhat it does
755rwxr-xr-x — standard for directories and executable scripts.
644rw-r--r-- — standard for regular files (web pages, configs, documents).
700rwx------ — private directory: only the owner has any access.
600rw------- — private file, e.g. SSH keys and credentials.
u+xSymbolic mode: add execute for the user (owner) only.
g-wRemove write permission from the group.
a+rGive read permission to everyone (all).
-RRecursive: apply to a directory and everything inside it.

How to use chmod: examples

$ chmod +x deploy.sh

Make a script executable — by far the most common chmod you will ever type.

$ chmod 755 script.sh

Owner: read, write, execute. Group and others: read and execute.

$ chmod 644 index.html

Owner can edit; everyone else can only read. The normal mode for web files.

$ chmod 600 ~/.ssh/id_ed25519

Lock a private key down to its owner. SSH refuses keys with looser permissions.

$ chmod -R 755 public_html/

Apply recursively to a whole directory tree.

$ chmod u+x,g-w notes.sh

Symbolic modes can be combined: add execute for the owner and remove write for the group.

Real-world use cases for chmod

Fixing SSH key permissions

ssh refuses to use a key with "UNPROTECTED PRIVATE KEY FILE" — by design. chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_ed25519 restores the exact permissions SSH demands. This pair of commands has unlocked more stuck logins than any other fix in Linux.

Preparing a web release

After uploading a site: find . -type d -exec chmod 755 {} + and find . -type f -exec chmod 644 {} + set the canonical web permissions — directories enterable, files readable, nothing executable that shouldn't be. Cleaner and safer than any recursive chmod.

Try chmod yourself

This is a live sandbox with a small filesystem (documents/, notes.txt, backup.sh…). Nothing you do here can break anything — experiment freely. Try: chmod 755 backup.sh

Pro tips and common mistakes

Frequently asked questions about chmod

What does chmod 755 mean?

Each digit is owner/group/others. 7 = 4+2+1 = read+write+execute for the owner; 5 = 4+1 = read+execute for group and for others. In symbols: rwxr-xr-x.

What is the difference between chmod 755 and 644?

755 includes the execute bit (needed to run scripts and to enter directories); 644 does not. Rule of thumb: 755 for directories and executables, 644 for regular files.

Why is chmod 777 a bad idea?

777 gives every user on the system full write access to the file. On servers this is a security hole: any compromised process can modify your files. There is almost always a correct narrower permission.

How do I make a file executable?

chmod +x filename adds the execute bit for everyone; chmod u+x filename adds it only for you.

Related commands

ls

List the contents of a directory, with options for hidden files, long format, sorting and more.

touch

Create empty files instantly, or update the timestamps of existing ones.

find

Locate files anywhere in a directory tree by name, type, size, date — and act on them.

Want to build real fluency? The interactive course takes you through chmod and every other essential command with guided, checked exercises.