Reading ls -l

What this is. Every file records who is allowed to do what with it. ls -l shows that as a ten character string at the start of each line, and it looks like noise until you know it is four fields joined together.

`

-rwxr-xr--

`

The first character is the kind: - for a file, d for a directory.

The next three are what the owner may do.

The next three are the group.

The final three are everyone else.

Reading the nine bits

A SCRIPT

-rwxr-xr--

-    ordinary file
rwx  owner: read write execute
r-x  group: read and execute
r--  others: read only

A DIRECTORY

drwxr-xr-x

d    a directory
rwx  owner: full access
r-x  group: enter and list
r-x  others: enter and list
Compare → The letters are always in the same order, r then w then x, and a dash means that permission is absent. Once you see it as three groups of three, the string reads left to right as owner, group, everyone.

✦ Execute means something different on a directory

On a file, x means this can be run as a program. On a directory, x means you may enter it and reach things inside. A directory with r but not x lets you list the names but not open anything within, which produces genuinely confusing permission denied errors on files that look perfectly readable.

SANKOFA SANDBOX
learner:~$

Try it → Run `ls -l` in your home directory, then `ls -l scripts`. Compare the first character on the directory lines with the file lines, and notice which entries have an x.

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: chmod, and Why Scripts Need +x →
← Back