The ls -l command shows a series of rwx letters next to each file: those
are the permissions. They decide who can read, change or run a file. Knowing
how to read them is essential before changing them, and that is what this
guide is about.
What you will learn
- Decode each column of
ls -l - Understand r, w, x applied to a file
- Understand r, w, x applied to a directory
- Tell apart the owner, the group and the others
- Know the role of umask (default permissions)
How do you read the output of ls -l?
ls -ltotal 20-rw-rw-r-- 1 bob bob 2048 Apr 6 2025 archive.tardrwxrwxr-x 2 bob bob 4096 Nov 20 10:00 projects-rw-r--r-- 1 bob bob 4096 Nov 20 10:00 report.txt-rwxr-x--- 1 bob dev 8192 Nov 20 10:00 script.shThe first line, total 20, gives the disk space used by the listed files, in 1 KB blocks. The following lines are sorted alphabetically by name.
Each line reads from left to right:
| Position | Example | Meaning |
|---|---|---|
| 1st character | - or d | Type: - = file, d = directory, l = link |
| Characters 2-4 | rw- | Rights of the owner (user) |
| Characters 5-7 | r-- | Rights of the group |
| Characters 8-10 | r-- | Rights of the others (everyone else) |
| Number | 1 | Number of links (no effect on the rights) |
| Name 1 | bob | Owner of the file |
| Name 2 | bob | Group of the file |
| Size | 4096 | Size in bytes |
| Date and time | Nov 20 10:00 | Date and time of last change (the year replaces the time for an old file) |
| Name | report.txt | Name of the file or directory |
The last three lines in the example come from recent changes, so ls -l shows the time (10:00). archive.tar is more than six months old, so ls -l shows the year instead of the time (Apr 6 2025). A file dated in the future, because of a wrong clock, also gets the year. This rule comes from the GNU coreutils documentation ("Formatting file timestamps").
The day and the month name depend on the system language. The example above comes from a C.UTF-8 session, which shows English month names (Apr, Nov) with the month before the day. With the fr_FR.UTF-8 locale, the same directory displays like this:
total 20-rw-rw-r-- 1 bob bob 2048 6 avril 2025 archive.tardrwxrwxr-x 2 bob bob 4096 20 nov. 10:00 projects-rw-r--r-- 1 bob bob 4096 20 nov. 10:00 report.txt-rwxr-x--- 1 bob dev 8192 20 nov. 10:00 script.shThe day comes before the month, and long month names are abbreviated: nov., déc., janv., but avril is written in full, like mars, mai, juin and août. The date column has a fixed width, hence the padding spaces.
On RHEL and its derivatives, the rights are often followed by an eleventh character, a dot (-rw-r--r--.). It means that the file has an SELinux context, the access control system of RHEL. It does not change how you read the rights. A + in that place means that the file also has ACLs.
What do r, w and x mean?
The same three letters apply to files and to directories, but they do not protect the same thing. On a file they protect its contents; on a directory they protect its list of names.
On a file
| Permission | Letter | Meaning |
|---|---|---|
| Read | r | Read the contents of the file |
| Write | w | Change the contents of the file |
| Execute | x | Run the file (script, program) |
A dash - in place of a letter means that the permission is absent.
Concrete examples:
| Permissions | Meaning |
|---|---|
rw- | Read and write, no execute |
r-- | Read only |
rwx | Every right |
--- | No right |
On a directory
The same letters have a different meaning for directories:
| Permission | Letter | Meaning on a directory |
|---|---|---|
| Read | r | List the contents (ls) |
| Write | w | Create, rename or delete files in the directory (with x) |
| Execute | x | Enter the directory (cd) and reach the files |
To read the rights of a directory itself, and not those of the files it contains, add -d to ls -l:
ls -ld projectsdrwxrwxr-x 2 bob bob 4096 Nov 20 10:00 projectsThe leading d marks a directory, and rwxrwxr-x reads as for a file: the owner and the group can list, enter and create files, the others can only list and enter. Without -d, ls -l projects would show the contents of the directory.
Deleting a file: the directory decides
This point is surprising. Deleting a file does not write to the file: the operation removes its name from the directory that holds it. rm does this through the unlink system call, a kernel function that removes a name from a directory. The rights checked are therefore those of the directory, not of the file: you need the w (change the list of names) and the x (go through the directory to reach the file).
A file with no rights at all (----------) can therefore be deleted if you have the w on its directory. Conversely, a file in rwxrwxrwx cannot be deleted in a directory where you do not have the w. The permissions of a file protect its contents; those of the directory protect its name and its existence.
For the file with no rights, rm asks for confirmation in a terminal (rm: remove write-protected regular empty file 'zero'? on Debian 13 for an empty file). Without a terminal, for example in a script, it deletes without asking, and rm -f never asks for confirmation.
Three exceptions reverse this rule, documented in unlink(2):
- the sticky bit (
chmod +t, thetof/tmp): in a shared directory, only the owner of the file (or of the directory, or root) can delete it, even if everyone has thew; - the immutable attribute (
chattr +i): deletion refused, even to root, whatever the permissions; - a file system mounted read-only: no deletion possible.
What are the three levels of rights?
The 9 permission characters are split into three groups of three:
rwx r-x r-- ─── ─── ─── u g o| Level | Letter | Applies to |
|---|---|---|
| User (owner) | u | The owner of the file |
| Group | g | The members of the file's group |
| Others | o | Every other user |
The system checks the rights in this order:
- Are you the owner? →
urights apply - Are you a member of the group? →
grights apply - Otherwise →
orights apply to the others
The animation shows how the kernel decides on an access. Choose who asks (bob the owner, alice from the group, eve another user), the action and the rights on the file, then see which series of rights stays lit: only one is examined. With "Delete", the kernel reads the rights of the directory, not those of the file. The animation leaves out root, ACLs and the deletion exceptions listed above.
- the request targets this file or folder
- rights read by the kernel
- the kernel moves on
- series used, or access granted
- access denied
- not checked
Play starts the voice and moves through the steps. The left and right arrows change step.
Your turn: try it
Each action starts from what the diagram shows. Restart goes back to the guided tour.
How do you decode common examples?
| Permissions | Who can do what |
|---|---|
-rw-r--r-- | Owner reads and writes. Group and others only read. |
-rwxr-xr-x | Owner has every right. Group and others read and execute. |
-rwx------ | Only the owner has access. Nobody else can do anything. |
drwxr-xr-x | Directory open to everyone, but only the owner can create files in it. |
To practise, run ls -la in your home directory:
ls -la ~/Try to decode each line: who is the owner? which group? which permissions for each level?
Your turn
The file journal.txt is -r--r--r-- (read-only for everyone). You own the file and the directory that holds it, a drwxr-xr-x directory. Can you change its contents? Can you delete it?
A hint
For each action, ask yourself what it touches: the contents of the file, or the list of names in the directory.
I have tried: show the answer
You cannot change the contents: as the owner of the file you fall in the u block, which is r-- and gives no w. You can delete it: the directory gives you rwx as its owner, so you have the w and the x needed to remove a name from its list. The rights of the file do not count for deletion.
What does umask do?
When you create a file, it does not get rwxrwxrwx by default. A mask
called umask automatically removes some permissions.
Rights and the umask can also be written with digits, using the octal notation: one digit per level, in the order owner, group, others. Each letter is worth a number, r = 4, w = 2 and x = 1, and a digit is the sum of the letters present: rw- makes 4 + 2 = 6, r-x makes 4 + 1 = 5, r-- makes 4. So rw-r--r-- is written 644 and rwxr-xr-x is written 755. The guide Change rights with chmod, chown and chgrp teaches how to set them. An extra leading 0 (0022) stands for the special rights, such as the sticky bit: read the last three digits.
umask0022The value depends on the distribution and the account. On Debian 13, root gets 0022, and an account created with useradd with its own group of the same name (bob in the group bob) gets 0002, which leaves w to the group. The examples on this page use 022.
The 022 umask means that the w permission is removed for the group and
for the others: the 0 removes nothing from the owner, each 2 removes the w. The umask does not do a subtraction: each digit
designates bits to remove, and a bit that is absent from the start stays
absent. That is why a new file, which starts without x, never gains one:
| Creation | Without umask | With umask 022 | Result |
|---|---|---|---|
| File | 666 (rw-rw-rw-) | w removed for group and others | 644 (rw-r--r--) |
| Directory | 777 (rwxrwxrwx) | w removed for group and others | 755 (rwxr-xr-x) |
Troubleshooting
Most permission errors come down to a level you did not expect, or to a
directory on the path rather than the file itself. Before changing
anything, read the rights of the file and of its parent with ls -ld.
| Symptom | Likely cause | Fix |
|---|---|---|
Permission denied when reading a file | No r right for your level | Check with ls -l and ask the owner |
Permission denied when entering a directory | No x right on the directory | Check with ls -ld directory/ |
| A new file is readable by everyone although it should not be | Default umask 022, which leaves r to others | umask 077 in the session (no rights for the group and the others), or chmod on the file already created, see Change rights |
ls works but cat file does not | Two possible causes: the file has no r right for your level (and cd into the directory succeeds), or the directory has r without x (and cd fails) | Try cd directory/: if it succeeds, read the rights of the file with ls -l; otherwise the directory is missing the x |
Key points
ls -lshows permissions in the formrwxrwxrwx: owner, group, others.- r = read, w = write/change, x = execute (file) or enter (directory).
- The system checks a single level: user → group → others, in that order.
- Deleting a file depends on the directory (
w+x), not on the file: a file with no rights at all (----------) is not protected from deletion. Exceptions: sticky bit,chattr +i, read-only file system. - umask decides the default permissions of new files:
022gives644to files and755to directories. - For a file older than six months or dated in the future,
ls -lshows the year instead of the time.
Knowledge check
Check that the essentials of this guide stuck. The questions cover only what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Change permissions with chmod, chown and chgrp
A new full quiz with random questions
Work again only on the questions you missed