Linux Mastery
The Human Knowledge Project
Chapter 09 — Permissions & Ownership
Why This Chapter Matters
Imagine using a computer where every person could read, modify, or delete every file—including the operating system itself.
One careless mistake could destroy another person's work.
One malicious program could damage the entire system.
Linux prevents this through a carefully designed system of permissions and ownership.
Every file and directory has an owner. Every user has defined privileges. Every action is governed by permissions that determine who may read, modify, or execute information.
Understanding this system is one of the most important steps toward becoming a confident Linux user and a capable system administrator.
Learning Objectives
Upon completing this chapter, you will be able to:
- explain why Linux uses permissions
- identify file owners, groups, and others
- interpret Linux permission strings
- distinguish read, write, and execute permissions
- change permissions using
chmod - understand numeric (octal) permissions
- change file ownership with
chown - explain the purpose of user groups
- understand when and why
sudois used
Introduction
Linux was designed from the beginning as a multi-user operating system.
Unlike early personal computers, Linux assumes that many users may be working on the same system simultaneously.
For that reason, every file, directory, and program has rules that determine who may access it and what actions are allowed.
These rules protect both users and the operating system itself.
In this chapter we will learn how Linux controls access to information and why permissions are one of the foundations of Linux security.
1. Why Permissions Matter
Linux systems may have:
- multiple users
- multiple administrators
- background services
- scheduled jobs
- network users
- software running automatically
Without permissions, every user would have unrestricted access to every file.
That would quickly lead to:
- accidental deletion
- unauthorized modification
- damaged software
- privacy violations
- unstable systems
Permissions allow Linux to determine exactly who may perform each action.
THKI Memory Aid
Owner ↓ Mine Group ↓ Our Team Others ↓ Everyone Else
Whenever you examine Linux permissions, think in terms of these three categories.
2. Viewing Permissions
To display file permissions:
ls -l
Example output:
-rw-r--r-- 1 norm norm 2048 Jun 12 notes.txt
The first field:
-rw-r--r--
describes the file type and its permissions.
Everything that follows describes ownership, size, date, and filename.
3. Understanding Permission Strings
Linux permissions use three symbols.
| Symbol | Meaning |
|--------|---------|
| r | Read |
| w | Write |
| x | Execute |
Example:
rw-
means:
- readable
- writable
- not executable
Each permission string is divided into three groups.
Example:
-rwxr-xr--
Breaking it apart:
- rwx r-x r--
│ │ │ │
│ │ │ └── Others
│ │ └──────── Group
│ └────────────── Owner
└─────────────────── File type
The first character indicates the file type.
A dash (-) represents a regular file.
Other symbols represent directories, links, and special filesystem objects.
THKI Insight
Most beginners try to memorize permission strings.
Experienced Linux users simply read them from left to right.
4. Permission Categories
Linux divides permissions into three categories.
| Category | Meaning |
|----------|---------|
| Owner | The user who owns the file |
| Group | Members of the assigned group |
| Others | Everyone else |
Think of these categories as answering three questions:
- What may I do?
- What may my group do?
- What may everyone else do?
Once you understand these three categories, Linux permissions become much easier to interpret.
5. Changing Permissions with chmod
The chmod command changes file permissions.
Example:
chmod u+x script.sh
Meaning:
u= user (owner)+= add permissionx= execute
The command grants the owner permission to execute the file.
Another example:
chmod go-r secret.txt
Meaning:
g= groupo= others-= remove permissionr= read
This command removes read permission from both the group and everyone else.
6. Numeric (Octal) Permissions
Linux permissions may also be represented using numbers.
| Value | Permission |
|-------:|------------|
| 4 | Read |
| 2 | Write |
| 1 | Execute |
These values are added together.
Examples:
| Number | Permissions |
|-------:|-------------|
| 7 | rwx |
| 6 | rw- |
| 5 | r-x |
| 4 | r-- |
Example:
chmod 755 script.sh
Which produces:
| Category | Permission |
|----------|------------|
| Owner | rwx |
| Group | r-x |
| Others | r-x |
Another example:
chmod 644 notes.txt
Which produces:
| Category | Permission |
|----------|------------|
| Owner | rw- |
| Group | r-- |
| Others | r-- |
Numeric permissions are widely used throughout Linux documentation and system administration.
7. Ownership
Every file in Linux has:
- an owner
- an associated group
Ownership determines who has primary control over a file.
To change ownership:
sudo chown user filename
Example:
sudo chown norm notes.txt
To change both the owner and the group:
sudo chown norm:students notes.txt
Ownership affects:
- access
- editing rights
- security
- administration
8. Groups
Linux groups allow multiple users to share access to files and directories.
Rather than assigning permissions individually to every user, Linux allows users with similar responsibilities to belong to the same group.
Common groups may include:
- students
- developers
- audio
- video
- sudo
To display the groups to which you belong:
groups
Groups simplify:
- collaboration
- shared access
- system administration
THKI Insight
Groups allow administrators to manage permissions for many users at once rather than configuring each user individually.
9. Executable Files
Programs and scripts normally require execute permission before Linux will allow them to run.
Grant execute permission:
chmod +x script.sh
Execute the script:
./script.sh
Without execute permission, Linux will usually refuse to run the file.
Remember:
- Read allows viewing.
- Write allows modification.
- Execute allows running.
These three permissions form the foundation of Linux access control.
10. Using sudo
Linux protects important administrative functions through elevated privileges.
The sudo command temporarily allows an authorized user to execute commands as the superuser.
Example:
sudo apt update
The word:
sudo
means:
superuser do
Use sudo carefully.
Administrative commands may:
- install software
- modify system configuration
- remove files
- change permissions
- affect every user on the computer
THKI Memory Aid
Normal User ↓ Limited Power sudo ↓ Temporary Administrator
11. Directory Permissions
Directories also use r, w, and x, but their meanings differ slightly from ordinary files.
| Permission | Meaning for Directories |
|------------|-------------------------|
| r | List directory contents |
| w | Create or delete files |
| x | Enter (traverse) the directory |
Directory permissions are often more important than file permissions because they control access to entire collections of files.
12. Linux Security
Linux permissions are one of the foundations of system security.
Good security practices include:
- using
sudoonly when necessary - protecting important files
- limiting write access
- understanding ownership
- keeping software updated
- assigning users to appropriate groups
Linux security is based on the principle of granting only the permissions that are actually required.
This principle is often called the Principle of Least Privilege.
THKI Insight
Good security is usually achieved by preventing mistakes before they happen—not by repairing damage afterward.
13. Practice Exercises
1.
Create a practice file:
touch practice.txt
Display its permissions:
ls -l
2.
Add execute permission:
chmod +x practice.txt
Display the updated permissions:
ls -l
3.
Assign numeric permissions:
chmod 644 practice.txt
Observe the permission changes.
4.
Create a simple script:
touch testscript.sh
chmod +x testscript.sh
5.
Display the groups to which you belong:
groups
6.
Display file ownership:
ls -l
Observe:
- owner
- group
7.
Create a directory:
mkdir secure_dir
Display its permissions:
ls -ld secure_dir
8.
Run:
sudo apt update
Observe how Linux requests your password before granting administrative privileges.
Chapter Summary
| Concept | Purpose |
|---------|---------|
| Permissions | Control access to files and directories |
| Owner | Primary controller of a file |
| Group | Shared access for multiple users |
| Others | Everyone else |
| chmod | Change permissions |
| chown | Change ownership |
| sudo | Temporarily obtain administrative privileges |
Key Ideas
Linux protects users and systems through a carefully designed permission model.
Understanding:
- ownership
- groups
- read, write, and execute permissions
chmodchownsudo
is essential for effective Linux administration.
Permissions are one of the defining strengths of Unix and Linux system design.
Looking Ahead
Now that you understand who may access files and what actions are permitted, we are ready to explore one of the most important Linux skills: creating and modifying files.
In the next chapter, we will begin working with Linux text editors and learn how to create, edit, and manage text efficiently from both the command line and graphical environments.