$_ CLI In Depth
Learning progress 0%
lesson permissions users sudo

Reading Permission Bits

6 min read Module 5: Users, Permissions & sudo Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:18

The ten characters in ls -l

When you run ls -l, each line begins with ten characters. The first character is the file type. A hyphen means a regular file, a letter d means a directory, and an l means a symbolic link. The remaining nine characters are three groups of three, and each group describes one class of user. The first group applies to the owner of the file, the second to the group, and the third to everyone else.

Inside each group, the letters stand for read, write, and execute, in that order. The letter r means read, w means write, and x means execute. A hyphen in the place of a letter means that permission is missing. So a mode such as -rw-r----- says that the owner can read and write, the group can only read, and everyone else has no access at all.

BASH1 lines
ls -l /workspace

The listing shows the mode first, then the link count, the owner name, the group name, the size, the modification time, and the name. Only the first ten characters are the permission bits, but the owner and group columns tell you whose bits apply to you. The link count is a different matter and is covered in the filesystem module.

Which class applies to you

The kernel does not combine the three classes. It picks exactly one of them for each access. If your UID matches the file owner, only the owner triplet is checked, even when the group or the other triplet would allow the access. If your UID does not match but one of your group IDs matches the file group, only the group triplet is checked. Otherwise the other triplet decides.

This rule surprises people who expect permissions to add up. Take a file with mode ----rwx that you own. The owner triplet is empty, so you cannot read, write, or run it, even though the other triplet would let everyone do all three. Being the owner does not borrow bits from the other classes. The owner triplet is the only one that applies to you.

Octal notation

The same nine bits can be written as one octal digit per triplet. Read permission is worth 4, write is worth 2, and execute is worth 1. You add the values inside each triplet. So rwx is 7, r-x is 5, r-- is 4, and --- is 0. A mode of rw-r----- becomes 6, 4, 0, which is written as 640.

Octal is shorter and easier to type, which is why it appears in scripts and in documentation. Symbolic notation is easier to read when you change one bit at a time. You will use both forms in the next unit. The important habit is to be able to translate between them in your head, because a command that changes the wrong digit is one of the most common ways to break a file.

Reading stat output

The stat command reports the mode directly, and you choose the format with -c. The %A format gives the symbolic mode, %a gives the octal mode, and %n gives the file name. Using stat is more reliable than counting characters in ls output, especially when you need the octal value for a script.

BASH3 lines
touch notes.txt
chmod 640 notes.txt
stat -c "%A %a %n" notes.txt

The output is one line with the symbolic mode, the octal mode, and the name. For a file set to 640, the line reads -rw-r----- 640 notes.txt. The command chmod is explained in the next unit, so for now you only need to recognize the result it prints.

Tip

When a permission problem puzzles you, print the symbolic mode, the octal mode, and the owner and group. Then ask which triplet the kernel would use for your UID. Nine times out of ten the answer is visible in that output.

Common mistakes when reading modes

The most frequent mistake is reading the owner triplet as if it described your own access. The owner triplet describes what the owner can do, and it applies to you only when your UID matches the owner. Many people look at a file owned by someone else, see that the owner has no write bit, and conclude that nobody can write it. The group or other triplet may still allow the access, and the kernel uses whichever one matches your identity.

A second mistake is confusing the link count with a permission. In ls -l the column after the mode is the number of hard links, and a directory usually shows at least two. That number is not a permission, and it does not change how the kernel checks access. Keep the mode, owner, and group in mind when you read a listing, and treat the other columns as context.

The third mistake is applying file meanings to directories. On a directory, the x letter means search, not run. A directory with mode rw-r--r-- is readable but not searchable, and that combination produces the strange behavior described in the directory unit. Read the letters in the same order for files and directories, but remember what each letter means for each type.

Symbolic links are a special case. On Linux a symbolic link always shows the mode lrwxrwxrwx, and that value is not used for any check. The permissions that matter belong to the target file, so you must read the target with stat to learn what you may do with it.

Practice reading modes on purpose. Create a few files with different modes, and for each one predict who may read and who may write before you check with stat. The prediction takes a few seconds, and it is the fastest way to build the habit that the later units rely on.

Hands-on: read the bits of a file you own

Create a file, set its mode to 640, and read the result with stat. Then read the same file with ls -l and check that the two views agree. The labs for this unit ask you to record the symbolic and octal forms in a file, and to split the mode of a script into its three triplets. Those are the two skills that every later unit depends on.

Reading, changing and defaulting permission bits

Visualizer

A mode is nine bits in three triplets. Decode one, change it with chmod, then see how umask produces the defaults for new files and directories.

1 / 4
-type
rowner
w
-
rgroup
-
-
-other
-
-
mode
-rw-r-----

The first character is the file type: - regular file, d directory, l symlink. The next nine are three triplets: owner, group and other, each with r, w and x.

f="$(mktemp -d /tmp/perm.XXXX)/p.txt"; touch "$f"; chmod 640 "$f"; stat -c "%a %A %n" "$f"
Terminal lab · 2 steps · real Linux in your browser

Reading Permission Bits

Read the symbolic and octal modes of a file and split the mode of a script into its three triplets.

01
Read the modes of a file
The file /workspace/perm/a.txt already exists. Do not change its mode. Use stat -c %A and stat -c %a on that file. Save the symbolic mode on line 1 and the octal mode on line 2 of /workspace/perm/answers.txt.
Show hint for step 1
Use > for the first stat and >> for the second, so both values end up in the file.
02
Split a mode into triplets
Read the symbolic mode of /workspace/perm/b.sh with stat. Write its owner, group, and other triplets on one line in /workspace/perm/triplets.txt, separated by single spaces.
Show hint for step 2
The symbolic mode starts with the file type, so the owner triplet is characters 2 to 4.
Check yourself Question 1 of 4
Concept Check The first character recall

In the ls -l line -rwxr-x---, what does the first character tell you?

Recap & Key Takeaways

The first character of ls -l is the file type, and the next nine characters are owner, group, and other triplets of r, w, and x.
The kernel picks one class, owner, group, or other, for each access, and it does not add the classes together.
Each triplet is one octal digit, with r worth 4, w worth 2, and x worth 1, so rw-r----- is 640.
stat -c with %A and %a prints the symbolic and octal modes directly, which is more reliable than reading ls output by eye.

Primary Sources & Further Reading

Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue