Introduction
Welcome back! In our last lesson, you mastered one of the most powerful features of the Linux shell: I/O redirection and pipes. You learned how to control the flow of data from commands, save output to files, and chain tools together to create powerful one-liners. This gives you control over what data goes where.
Today, we're shifting our focus to a cornerstone of Linux security: the permission model. This lesson will teach you how to control who can do what with files and directories. Our goal is to explain the Linux permission model (owner, group, others) and interpret permission strings like rwxr-xr--.
For your goal of becoming a skilled ethical hacker, this is non-negotiable knowledge. Misconfigured permissions are a common vulnerability that can allow an attacker to read sensitive data, modify critical files, or escalate their privileges on a system. By understanding this model deeply, you'll learn how to spot these weaknesses and how to secure your own systems.
Understanding Permissions with ls -l
In previous lessons, you've used ls to list files. The -l flag provides a "long" listing format, which is packed with information, most importantly the permission string.
Let's start by watching a video that breaks down the output of ls -l and introduces the fundamental concepts.
Linux Crash Course - Understanding File & Directory Permissions
This segment from Learn Linux TV's 'Understanding File & Directory Permissions' clearly breaks down the ls -l output. It explains how the permission string is divided into four main parts: file type, owner permissions, group permissions, and others permissions.
Watch from 00:47 to 02:49. Pay close attention to how the 10-character string is segmented.
As the video explained, the permission string is structured into four parts:
- File Type (1 character):
dfor directory,-for a regular file,lfor a symbolic link, etc. - Owner/User Permissions (3 characters): What the file's owner can do.
- Group Permissions (3 characters): What members of the file's group can do.
- "Others" Permissions (3 characters): What everyone else on the system can do.
These three categories—User, Group, and Others—are often abbreviated as UGO.

The "What": Read, Write, and Execute Permissions
Now that we know who the permissions apply to (UGO), let's define what they can do. The three basic permissions are Read (r), Write (w), and Execute (x). Crucially, their meaning changes depending on whether they are applied to a file or a directory.
This is a critical distinction that can trip up even experienced users. The next segment of the video provides a very clear explanation.
Linux Crash Course - Understanding File & Directory Permissions
Let's continue with the 'Learn Linux TV' video. These next clips meticulously detail the meaning of Read (r), Write (w), and Execute (x) for both files and directories.
Watch from 03:51 to 10:37. Focus on understanding the differences: Read (r): Viewing a file's content vs. listing a directory's contents. Write (w): Changing a file's content vs. creating/deleting files within a directory. Execute (x): Running a file as a program vs. entering (cd) a directory.
Here is a summary table for your reference:
| Permission | On a File | On a Directory |
|---|---|---|
| Read (r) | View the contents of the file. | List the names of the files inside the directory. |
| Write (w) | Modify or delete the file's contents. | Create, rename, or delete files within the directory. |
| Execute (x) | Run the file as a program or script. | Enter the directory (i.e., make it your current directory with cd). |
A common point of confusion is directory access. To cd into a directory, a user only needs execute (x) permission. However, to list its contents with ls, they need read (r) permission as well. This is why you'll often see directories with r-x permissions.
Putting It All Together: Reading the Code
Now you have all the pieces. Let's practice reading the "code" of permission strings.
Consider the following permission string from an ls -l output:drwxr-x---
Let's decode it step-by-step:
- **
d**rwxr-x--- : This is a directory. - d**
rwx**r-x--- : The owner has Read, Write, and Execute permissions. They can list, create/delete files in, andcdinto the directory. - drwx**
r-x**--- : Members of the group have Read and Execute permissions. They can list the contents andcdinto the directory, but cannot create or delete files. - drwxr-x**
---** : Others (everyone else) have no permissions at all. They cannotcdinto it, list its contents, or modify it in any way.
Let's watch one more quick clip that reinforces this with a few more examples.
Linux Crash Course - Understanding File & Directory Permissions
The final segment from the Learn Linux TV video demonstrates how to apply this knowledge to interpret the permissions of various files and directories in a typical home directory.
Watch from 10:29 to 14:51. Pay attention to the logic used to determine who can do what based on the r, w, and x characters in each UGO slot.
Hands-on Practice
Theory is essential, but practice builds skill. It's time to open your terminal on your Arch Linux system and apply what you've learned. We'll use a guided Q&A resource to test your interpretation skills.
Practice Linux Permissions Basics with 13 Easy Questions [Part I]
This article from Pentester Academy provides a series of challenge questions that are perfect for practicing your new skills. We will focus on the first few questions which are all about interpreting permissions.
Read through the solutions for questions 1 through 5. You don't need to set up their lab environment. The goal is to understand the logic. For each question, first look at the ls -l output they provide, try to answer it yourself, and then read their explanation to see if you were right.
After working through those examples, let's analyze some critical files on your own system. For each of the commands below, run it and answer the questions.
1. The Shadow Password File
Command: ls -l /etc/shadow
- Who is the owner?
- What group is it assigned to?
- What permissions does the owner have?
- What permissions does the group have?
- What about "others"?
- Security Question: Based on these permissions, who can read the file containing hashed user passwords? Why is this a secure configuration?
2. The Temporary Directory
Command: ls -ld /tmp (the -d flag shows information about the directory itself, not its contents)
- Look at the permissions for "others". What can any user on the system do in
/tmp? - Notice the last character is a
t, not anx. This is the "sticky bit," a special permission we'll cover later. For now, observe that it's different. - Security Question: Since everyone can write to
/tmp, what might prevent one user from deleting another user's files? (This is a hint about what the sticky bit does).
3. The Bash Executable
Command: ls -l /bin/bash
- Who owns this file?
- What permissions does the owner have?
- What permissions do "group" and "others" have?
- Security Question: Why is it essential for "others" to have execute permission on
/bin/bash? What would happen if they didn't?
Conclusion
Great work. You've just deciphered a fundamental component of the Linux operating system. Understanding permissions is not just an administrative task; it's a core security skill. Being able to look at a file listing and instantly know who has access and what they can do is crucial for both defending and assessing a system.
Key Takeaways:
- Linux file permissions apply to three classes of users: the User (owner), the Group, and Others.
- The three basic permissions are Read (r), Write (w), and Execute (x).
- The meaning of
r,w, andxis different for files than it is for directories. - The
ls -lcommand displays a 10-character string that encodes the file type and the permissions for the owner, group, and others (e.g.,-rwxr-xr--).
Next Lesson Preview:
You can now read and interpret permissions flawlessly. The next logical step is to change them. In our next lesson, you will learn how to use the chmod command with both symbolic (u+x, g-w) and numeric (755, 644) notation to modify file and directory permissions.