Linux Directory Structure and File System (Beginners to Pro Guide)

SeekLinux banner illustrating Linux directory structure and file system hierarchy for beginners to pro users

Introduction

Linux may seem intimidating at first, especially when you're greeted with folders like /etc, /var, /dev, and more. But once you understand the directory structure and file system hierarchy, navigating and managing your Linux system becomes much easier. Understanding the Linux directory structure is one of the most important skills for anyone starting with the Linux operating system.


Linux may seem intimidating at first, especially when you're greeted with folders like /etc, /var, /dev, and more. But once you understand the directory structure and file system hierarchy, navigating and managing your Linux system becomes much easier. Understanding the Linux directory structure is one of the most important skills for anyone starting with the Linux operating system.


1.    What is the Linux File System?
2.    The Root Directory and File System Hierarchy
3.    Linux File System Types
4.    Why Understanding the Linux File System Hierarchy Matters
5.    What is File Permissions in Linux?
6.   How to change Linux File Permissions Using chmod
7.   Special Permissions
8.   Security Tips

1. What is the Linux File System?

The Linux file system is a structured and standardized method of storing and organizing files on your Linux-based operating system. Unlike Windows, where drives like C:\ or D:\ represent partitions, Linux uses a single-rooted directory tree starting from / (called the root). Everything in Linux — files, directories, devices, and even processes — is treated as a file.


2. The Root Directory / and the File System Hierarchy
The top of the Linux file system is the root directory, denoted by /. All other files and directories stem from this root. Here's a breakdown of the most common directories you'll encounter.
Diagram of Linux directory structure showing root folder and key subdirectories like bin, etc, var, home
2.1 / - Linux Root Directory
This is the base of the file system. Every single file and directory starts from here.

2.2 Linux /boot­­­­ Directory
This is one of the most important directories in the Linux file system. The boot directory contains Linux boot files as the bootloader, kernel and its related files. Image of Linux kernel stays here in the form of a compressed file.

2.3 Linux /bin Directory— Essential User Binaries
Contains basic Linux commands needed for system boot and recovery, available to all users.

2.4 Linux /sbin Directory — System Binaries
It is like a /bin directory but contains essential system binaries meant for root or administrative users.

2.5 Linux /etc Directory — Configuration Files
This directory holds system-wide configuration files and scripts used to initialize settings for programs and services.

2.6 Linux /home Directory — User Home Directories
Each user gets a personal folder under /home. This is where personal documents, downloads, and settings are stored.

2.7 Linux /root Directory — Root User’s Home Directory
This is the home directory of the root user, not to be confused with / (the file system root).

2.8 Linux /var Directory — Variable Files
Used for data that changes frequently, such as logs, spool files, caches, etc.

2.9 Linux /usr Directory — User System Resources
Contains read-only user applications, documentation, libraries, and binaries.

2.10 Linux /tmp Directory — Temporary Files
Temporary data used by applications or the system. Files are typically deleted after a reboot.

2.11 Linux /dev Directory — Device Files
Represents hardware devices like hard drives, terminals, USBs as files.

2.12 Linux /proc and /sys Directory — Virtual File system
These directories contain runtime system information, generated on-the-fly.

/proc includes process data and kernel parameters.

/sys exposes hardware information.

2.13 Linux /lib Directory — Essential Shared Libraries
Libraries required by binaries in /bin and /sbin. They’re similar to DLLs in Windows.

2.14 Linux /media and /mnt Directory— Mount Points
/media: automatically mounted removable devices (USB drives, CDs).

/mnt: used for manually mounting file systems or drives.

3. Linux File System Types
Linux supports various file systems. Here are some common ones:

File System                       Description
Ext4                                  Default modern Linux file system; robust and fast
xfs                                    High-performance journaling file system
btrfs                                  Next-gen file system with snapshots and checksums
Vfat/fat32                          Used in USB drives and dual-boot environments
ntfs                                   Windows file system, supported via drivers

4. Why Understanding the Linux File System Hierarchy Matters

·       Helps in troubleshooting system errors
·       Makes you confident using terminal-based tools
·       Crucial for Linux administration, DevOps and certification exams
·       Prevents accidental deletion of critical files
·       Helps in partitioning and backup strategies

5. What is File Permissions in Linux?
In Linux, everything is a file — whether it’s a document, a device, or a program. Each file or directory has permissions that define who can read, write, or execute that file.
These permissions are applied to three categories:
·       Owner – the user who owns the file
·       Group – a group of users assigned to the file
·       Others – everyone else
Linux file system permissions and ownership illustration for different directories

Types of Linux File Permissions

Symbol                  Permission            Description
r                              Read                       View file content or list directory
w                             Write                       Modify file content or directory files
x                              Execute                  Run file as a program or enter directory

File Permission Examples

1. -rwxr--r--
·       Owner: can read, write, and execute
·       Group: read-only
·       Others: read-only

2. drwxr-xr-x
·       Directory
·       Everyone can enter the directory
·       Only owner can modify contents

6. How to Change Linux File Permissions Using chmod
The chmod command is used to change file modes or access permissions.

Symbolic Method
·       chmod u+x file.sh      # Add execute permission for user
·       chmod g-w file.sh      # Remove write permission for group
·       chmod o=r file.txt      # Set others to read-only

Numeric (Octal) Method
Each permission type has a value:

Permission  Value
·       Read (r)        4
·       Write (w)       2
·       Execute (x)   1

Directory Permissions
File permissions also apply to directories, but they work slightly differently:

Permission                       Effect on Directory
r                                        List contents of the directory
w                                       Create or delete files in the directory
x                                        Access files and subdirectories inside

7. Special Permissions

Set UID (s)
When set on executables, the program runs with the owner’s privileges, not the users.
·       chmod u+s program

Set GID (s)
When set on directories, new files inherit the group of the directory.
·       chmod g+s /data/shared

Sticky Bit (t)
Only the file owner or root can delete files in that directory.
Used commonly in /tmp:
·       chmod +t /tmp

8. Security Tips
·       Avoid giving 777 permissions — it gives full access to everyone
·       Use chmod -R cautiously — it applies changes recursively
·       Use groups to manage access to shared files

Conclusion

Mastering the Linux directory structure and understanding the Linux file system hierarchy is essential for both beginners and professionals. From the boot directory to important paths like /home, /var, /etc and /usr, each folder has specific purpose that keeps the system organized and functional. By learning how the Linux directory tree works and studying the functions of Linux directories, users can navigate confidently and troubleshoot issues with ease.

Please keep visiting seeklinux for more information and updates.

Post a Comment

Previous Post Next Post