Linux command list

chmod command: change file permissions

__ __ _ _____
\ \ / /__| |_|_ _|__ _ __ _ __ ___
\ \ /\ / / _ \ '_ \| |/ _ \ '__| '_ ` _ \
\ V V / __/ |_) | | __/ | | | | | |
\_/\_/ \___|_.__/|_|\___|_| |_| |_| |_
 
A sandbox for trying chmod. Nothing here can touch your real files.
user@webterm:~/project$
 

chmod changes who may read, write and run a file. Learn how to read rwx, what numbers like 755 and 644 mean, and when to use +x instead, by running the commands in a real terminal in your browser.

Updated: 2026-09-05

Syntax

chmod [options] mode file...

The mode is either a number such as 755, or a symbol such as +x.

Try it first

Start by looking at the current permissions with ls -l.

$ ls -l
total 16
-rw-r--r--   1  user  user     27  Sep  5 15:00  deploy.sh
-rw-r--r--   1  user  user     10  Sep  5 15:00  README.md
drwxr-xr-x   2  user  user   4096  Sep  5 15:00  scripts/
-rw-r--r--   1  user  user     14  Sep  5 15:00  secret.env

The ten characters on the left are the permissions.

PositionMeaning
1stType (- for a file, d for a directory)
2nd to 4thWhat the owner may do
5th to 7thWhat the group may do
8th to 10thWhat everyone else may do

r is read, w is write, x is execute. deploy.sh is -rw-r--r--, so it cannot be run yet.

Making a file executable

+x adds the execute permission.

$ chmod +x deploy.sh
$ ls -l deploy.sh
-rwxr-xr-x   1  user  user     27  Sep  5 15:00  deploy.sh

Three x characters appeared. The symbolic form adds to or removes from what is already set.

Using numbers

A digit is read 4 plus write 2 plus execute 1.

DigitWhat it allows
7Read, write, execute (4+2+1)
6Read and write (4+2)
5Read and execute (4+1)
4Read only
0Nothing

Three digits cover owner, group and others in that order. For something only you should read, that is 600.

$ chmod 600 secret.env
$ ls -l secret.env
-rw-------   1  user  user     14  Sep  5 15:00  secret.env

In practice two combinations cover most files.

$ chmod 644 README.md
$ ls -l
total 16
-rwxr-xr-x   1  user  user     27  Sep  5 15:00  deploy.sh
-rw-r--r--   1  user  user     10  Sep  5 15:00  README.md
drwxr-xr-x   2  user  user   4096  Sep  5 15:00  scripts/
-rw-------   1  user  user     14  Sep  5 15:00  secret.env

644 for ordinary files, 755 for things you run and for directories.

Changing a whole directory

-R applies the mode to everything inside as well.

$ chmod -R 755 scripts
$ ls -l scripts
total 4
-rwxr-xr-x   1  user  user     24  Sep  5 15:00  backup.sh

When you actually reach for it

chmod is what you run when permissions turn out to be the reason something will not work.

SituationWhat you type
Make a script runnablechmod +x deploy.sh
Keep a secret to yourselfchmod 600 .env
Put a file back to normalchmod 644 notes.txt
Fix a directory of scripts at oncechmod -R 755 scripts

Things that trip people up

Numbers replace, symbols adjust. chmod 755 ignores what was there and sets the whole thing. chmod +x only adds execute and leaves the rest alone, which is safer when something is already configured.

777 is not a fix. It lets anyone write to the file. Use it to prove a theory if you must, then put it back.

A missing file is an error.

$ chmod 777 nope.txt
chmod: cannot access 'nope.txt': No such file or directory

Sometimes the owner is the problem, not the mode. In that case you need chown, not chmod. ls -l tells you whose file it is.

Practise it hands-on

webterm.appthis site

  • Advanced Terminal Commands

    Learn commands for specific situations

    Try the tutorial

learn.webterm.appa separate site

>_WEBTERM LEARN

WebTerm Learn: from one command to actually using it

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.

See the course

Related commands

ls / chown / stat

Frequently asked questions

What do numbers like 755 and 644 mean?
Each digit covers owner, group and others, and is the sum of read 4, write 2 and execute 1. So 755 is read, write and execute for the owner and read plus execute for everyone else.
What does chmod +x actually do?
It adds the execute permission. A number replaces the whole set, while +x only adds to what is already there.
I got Permission denied. Should I run chmod?
Check ls -l first. If the permissions are wrong, chmod is right, but if the file belongs to someone else you need chown. Reaching for 777 is not the answer.
Why is 777 a bad idea?
It lets anyone modify the file. It is at most a temporary way to prove that permissions are the problem, never something to leave in place.
What does x mean on a directory?
Whether you can enter it. r lets you list the contents, x lets you reach the files inside.