Learn by reading through in order

Permissions — Reading Them and chmod

Learn to read the rwx notation and octal numbers in ls -l, rewrite permissions with chmod's symbolic and numeric modes, and the syntax of chown — hands-on in a browser terminal.

Reading Permissions — ls -l and Octal

Permissions are a setting for who can do what to a file or directory.

When you run ls -l, each line starts with 10 characters like -rwxr-xr-x.

The first character is the type (- for a file, d for a directory), and you read the next 9 in groups of three.

The 9 characters are three groups from the left: owner, group, and other.

Each group is in the order r (read), w (write), x (execute) — a letter if allowed, or - if not.

r=4, w=2, x=1 correspond to three binary bits, and you add the 4, 2, 1 places.

Adding up one group, rwx is 7, r-x is 5, and r-- is 4; line up three groups and you get octal notation like 755 or 644.

SymbolMeaningr4+w2+x1Number
---Nothing allowed00
--xExecute only11
r--Read only44
r-xRead + execute4+15
rw-Read + write4+26
rwxFull access4+2+17
Octalrwx notationUse
644rw-r--r--Regular files
755rwxr-xr-xScripts and directories
700rwx------Private keys, personal directories
600rw-------Config files
rwx to octal mapping
ownergroupotherrwx = r4+w2+x1r-x = r4+x1r-x = r4+x1= 7= 5= 5755
rwxr-xr-x reads as owner 7, group 5, other 5 — that is, 755.

Permissions here vs. on a production server

This browser environment runs as root alone, so even if you change bits with chmod, root ignores access restrictions and Permission denied doesn't appear.

In this course you learn how to read the bits and the syntax of chmod / chown.

You can actually see the ls -l display change.

On a multi-user production server, these permission settings work as access control.

touch report.txt        # create material
ls -l report.txt        # read the leading rwx notation
ls -l                   # list the directory to see d too

① Create a material file with touch report.txt.

② Run ls -l report.txt and read the rwx notation at the start of the line.

③ Split the 9 characters you read into groups of three and convert them to a 3-digit octal number by adding r=4, w=2, x=1.

④ List the whole current directory with ls -l and check the difference in the leading character between files and directories. (Run it correctly and an explanation will appear.)

Linux console
0 / 3 completed
Loading Linux Terminal...

Changing Permissions — chmod

chmod changes permissions.

There are two ways to write it: symbolic mode, where you specify with symbols like chmod +x file to 'add execute', and numeric mode, where you specify owner, group, and other together with a 3-digit octal number like chmod 644 file.

ModeHow to write itExampleMeaning
Symbolicchmod [ugoa][+-=][rwx]chmod +x fileAdd execute
Numericchmod NNN filechmod 644 fileSet all three groups at once
chmod symbolic mode and numeric mode
chmod +x run.shadd x (execute)for everyonechmod 644 data.txtset to rw-r--r--(rw / r / r)chmod 700 secret.txtset to rwx------(owner only, full)
The symbol +x adds execute, and the numbers 644 / 700 set all three groups at once.
touch script.sh             # create material
chmod +x script.sh          # add execute
ls -l script.sh             # check that x was added

① Create a material file with touch script.sh.

② Add the execute permission with chmod +x script.sh, and confirm with ls -l script.sh that an x was added to the leading notation.

③ Then run chmod 644 script.sh and confirm with ls -l script.sh that the notation changed to rw-r--r--.

Linux console
0 / 4 completed
Loading Linux Terminal...

Owner Only — chmod 700

chmod 700 gives the owner rwx and gives the group and other nothing.

It's the typical setting for things you don't want anyone but the owner to touch, like private keys or personal directories.

The display becomes rwx------.

① Create a material file with touch secret.txt.

② Run chmod 700 secret.txt.

③ With ls -l secret.txt, confirm the notation changed to rwx------ and the group and other fields are all -.

Linux console
0 / 3 completed
Loading Linux Terminal...

Changing the Owner — chown

chown is the command that changes the owner of a file or directory.

The syntax is chown user file, and to change the group too you write chown user:group file.

Here the : separates the user and group: before the : is the owner, and after it is the group.

How to write itMeaningExample
chown user fileChange the ownerchown alice file.txt
chown user:group fileChange the owner and groupchown alice:dev file.txt

Changing the owner is inherently a root operation, used on multi-user servers to hand a file over to a new owner.

There's no occasion to run it in this environment, so just read and learn the shape of the syntax in the next example.

chown alice file.txt        # change the owner to alice
chown alice:dev file.txt    # owner alice, group dev
QUIZ

Knowledge Check

Answer each question one by one.

Q1What is the octal for the -rwxr-xr-x shown at the start of ls -l?

Q2What does chmod +x script.sh do?

Q3What is the notation after running chmod 700 secret.txt?