Mastering the Linux File System: Permissions, Directories, and Commands
A Comprehensive Guide to Understanding the Linux File System: Directories, Permissions, and Advanced Commands
Introduction
Welcome back to our Linux learning series! In the last article (click here to read), we explored Linux installation methods and virtualization, setting the foundation for your Linux journey. Today, we’ll dive into the Linux file system, an essential part of understanding and using Linux effectively.
The file system in Linux is not just about organizing files — it’s a sophisticated structure that manages access, security, and data integrity. Whether you’re a developer, a cloud engineer, or a DevOps enthusiast, mastering the Linux file system is critical.
In this article, you’ll learn:
- The structure and components of the Linux file system.
- File and directory permissions and their impact on security.
- How to navigate, manipulate, and secure files using commands.
- Advanced concepts, such as symbolic and hard links.
- Practical examples and tips to apply your knowledge effectively.
By the end of this article, you’ll have a strong understanding of how Linux organizes and secures data.
The Structure of the Linux File System
The Linux file system is hierarchical, resembling an inverted tree. At the root of this tree is the /
directory, also known as the root directory. All files and directories are organized under it.
Key Directories in Linux
Here’s a quick overview of some critical directories:

Mermaid Diagram: Linux File System Hierarchy

Why is the File System Important?
The Linux file system is designed with flexibility, scalability, and security in mind. It enables multi-user systems to segregate data while maintaining access controls.
Understanding File Permissions in Linux
In Linux, every file and directory has a set of permissions that determines who can access it and how. These permissions ensure security and proper resource management.
The Permission Model
Permissions are defined for three entities:
- Owner: The user who created the file.
- Group: A collection of users with shared access.
- Others: Everyone else on the system.
Permission Types
Each file or directory can have three types of permissions:
- r (read): View the file or list the directory contents.
- w (write): Modify the file or add/remove files in a directory.
- x (execute): Run the file as a program or access the directory.

Viewing Permissions
Use the ls -l
command to view file permissions:
ls -l
Example output:
-rwxr-xr-- 1 user group 1024 Dec 12 10:00 example.txt
Explanation:
-rwxr-xr--
:
-
: File type (-
for files,d
for directories).rwx
: Owner permissions (read, write, execute).r-x
: Group permissions (read, execute).r--
: Others permissions (read-only).
Mermaid Diagram: File Permission Breakdown

Changing File Permissions
To modify file permissions, use the chmod
command.
Examples:
- Grant execute permission to the owner:
chmod u+x example.txt
2. Revoke write permission for the group:
chmod g-w example.txt
Using Numeric Permissions
Permissions can also be represented numerically:
r
= 4,w
= 2,x
= 1.- Add these values to define permissions (e.g.,
rwx
= 7).
Example:
chmod 754 example.txt
Explanation:
7
(Owner):rwx
.5
(Group):r-x
.4
(Others):r--
.
Essential Commands for Navigating the File System
Here are some must-know Linux commands to navigate and manage files effectively:
1. Navigating Directories
- List files:
ls
ls -l
- Change directory:
cd /path/to/directory
- Display current directory:
pwd
2. Creating and Deleting Files/Directories
- Create a file:
touch file.txt
- Create a directory:
mkdir new_directory
- Remove a file:
rm file.txt
- Remove a directory:
rm -r new_directory
3. Viewing and Modifying Files
- View file contents:
cat file.txt
- Edit files: Use a text editor like
nano
orvim
:
nano file.txt
List for Simplicity
Navigation Commands

Creating and Managing Files

Viewing and Editing Files

Advanced File System Concepts
Symbolic and Hard Links
- Symbolic Link: Acts as a shortcut to another file or directory.
ln -s target_file link_name
2. Hard Link: Points directly to the data blocks of a file.
ln target_file link_name
Practical Use Case: Linking Logs to /var/log
ln -s /home/user/app_logs /var/log/app_logs
Practical Examples
Example 1: Creating a Project Directory
mkdir ~/projects
cd ~/projects
touch README.md
ls -l
OR
mkdir -p ~/projects/my_app
cd ~/projects/my_app
touch README.md main.py
chmod 700 ~/projects/my_app
ls -l ~/projects/my_app
Example 2: Changing Permissions for Security
chmod 700 ~/projects
ls -l ~/projects
Best Practices for File Management
- Use Descriptive Names: Name files and directories clearly (e.g.,
report_2024.pdf
). - Organize by Folders: Keep related files in separate directories.
- Regular Backups: Use tools like
rsync
for backups. - Secure Sensitive Data: Restrict permissions for confidential files.
Relevant Documentation and Resources
What’s Next?
In the next article, we’ll explore Linux Package Management and Software Installation, where we’ll cover package managers, repositories, and advanced software installation techniques.