← All lessons
Files and permissions · Lesson 3 of 7

Reading permissions

Linux was built for many people sharing one machine, so every file says who may do what with it. ls -l shows it in the first column.

$ ls -l
-rw-r--r-- 1 sam  sam   1204 Oct 21 09:30 notes.txt
-rwxr-xr-x 1 sam  sam    310 Oct 21 09:31 backup.sh
drwxr-x--- 2 sam  staff 4096 Oct 20 17:02 shared

The first character is the type: - for a file, d for a directory, l for a link. The next nine are three sets of three: what the owner can do, what the file's group can do, and what everyone else (others) can do. The owner and group are the two names after the number.

Each set is r (read), w (write) and x (execute), with a - where that permission is missing. So rw-r--r-- means the owner can read and write, and the group and others can only read.

On a file, x means it can be run as a program. On a folder the letters mean something slightly different: r lets you list the names inside, w lets you create and delete files in it, and x lets you go into it (cd) and reach the files.

In the listing above, backup.sh can be run by anyone, and only sam can change it. shared is a folder that sam can use fully, people in the staff group can enter and list but not change, and others can't get in at all.

Practice

In -rw-r--r--, what can the group do?

More info

Quick reference

ls -lShows type, permissions, owner, group, size, date.
- d lFile, directory, link.
r w xRead, write, execute.
owner group othersThe three sets, in that order.
x on a folderYou may go into it.

The other Linux courses