If you are acquainted with the Linux ecosystem, you must be familiar with the terms like root, lib, bin, and more. All these are directories that you find in all Linux distributions.
In fact, the Linux file hierarchy system is a tribute that defines the directory structure and the purpose of them. However, it can get pretty confusing pretty fast, which is why this guide will walk through the Linux directory structure in detail with all the directories and their purpose!
Understanding the Root Directory (/) in Linux
The root directory is the top level directory in the Linux file system, which acts as a foundation for all the other files and directories. Every directory and file in Linux is organized in a hierarchy under the / sign, making it the start point for the system structure.
Key Aspects of the Root Directory (/)
- Top-Level Directory
- The / directory contains all system files, configurations, and user files.
- Unlike Windows, which has multiple drives (C:, D:, etc.), Linux has a single-rooted file system.
- Critical for System Operation
- Essential system files, including the kernel, boot files, and configuration settings, reside under /.
- Incorrect modifications can lead to system failures.
- Root vs. Root User
- / refers to the root directory (top-level system directory).
- /root is the home directory for the root (administrator) user.
Here is a table with quick descriptions of all the root directories in the file structure.
Directory | Description |
/ | The root directory; the top-level directory that contains all other directories and files. |
/bin | Stores essential binary executables (e.g., ls, cp, mv), available to all users. |
/sbin | Contains system administration binaries (e.g., fsck, iptables), usually restricted to root users. |
/etc | Stores configuration files for system-wide settings and services. |
/home | Contains user home directories, where personal files and settings are stored. |
/root | The home directory of the root user (administrator). |
/usr | Holds user utilities, libraries, and applications (e.g., /usr/bin, /usr/lib). |
/var | Stores variable data like logs (/var/log), mail (/var/mail), and temporary files. |
/tmp | A temporary storage directory for system and user files; cleared on reboot. |
/dev | Contains device files for hardware like disks (/dev/sda), USBs, and terminals. |
/proc | A virtual file system providing system information (processes, memory, CPU details). |
/sys | Similar to /proc, used for interacting with the kernel and hardware devices. |
/mnt | A generic mount point for attaching external storage (e.g., USBs, network drives). |
/media | Automatically mounts removable media like USB drives and CDs. |
/opt | Used for optional third-party software installations. |
/srv | Stores data for services like web servers (/srv/www), FTP, or databases. |
/lib | Contains essential shared libraries required by /bin and /sbin binaries. |
/lib64 | Stores 64-bit libraries on 64-bit systems. |
/boot | Holds bootloader files and the Linux kernel (vmlinuz), necessary for booting. |
/run | Stores runtime data like process IDs (/run/lock, /run/shm); replaces older /var/run. |
Key Linux Directories and Their Functions
The Linux file system follows a pre-set hierarchy, which shows that each root directory serves a well-thought out function. Here is a breakdown of Linux directory structure with the most important directories and their purposes.
- /bin – Essential User Binaries
This directory contains essential command-line utilities used by all the users, including non-root users. Examples: ls, cp, mv, cat, echo, grep.
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
- /sbin – System Binaries
In the Linux directory structure, /sbin stores the system administration commands, typically used by the root user. Examples: fsck, iptables, reboot, shutdown, mount.
- /etc – Configuration Files
The /etc configuration files hold system-wide configuration files and startup scripts. Examples: /etc/passwd (user accounts), /etc/fstab (disk mount settings).
- /home – User Home Directories
The /home is a personal directory for each individual user to store files, settings, and configurations. Example: /home/alex/Documents/ for user “alex”.
- /var – Variable Data (Logs, Caches, etc.)
The /var is a variable data directory that stores all the frequently changing data variables like logs, mails, caches, and temp files. Examples: /var/log/syslog, /var/cache/apt, /var/www (web server files).
- /usr – User Programs and Utilities
In the Linux directory structure, /usr contains user-related programs and libraries and is usually installed by the system package manager. Examples: /usr/bin/ (user applications), /usr/lib/ (libraries).
- /opt – Optional Software Packages
The /opt directory stores third-party applications and softwares that are installed manually. Examples: /opt/google/chrome/ for Google Chrome installation.
- /tmp – Temporary Files
In the Linux directory structure, the /tmp file is used to store temporary files, automatically cleared on reboot. Example: /tmp/session123.tmp.
- /dev – Device Files
The /dev, also known as the device files contains special device files that represent hardware components. Examples: /dev/sda (hard drive), /dev/tty (terminal), /dev/null.
- /mnt and /media – Mount Points
In the Linux directory structure;
- /mnt: Temporary mount location for external drives or network shares.
- /media: Automatically mounts removable media like USBs and CDs.
- /proc and /sys – Kernel and System Information
In the Linux directory structure;

- /proc: A virtual file system containing system information, including process details. Example: /proc/cpuinfo (CPU details).
- /sys: Exposes hardware and kernel-related parameters. Example: /sys/class/net/ (network interfaces).
How to Navigate the Linux File System
It is important to understand how to navigate the Linux directory structure to efficiently manage files, directories, and the system resources. Here is how you can move through the system efficiently:
- Understanding the Linux Directory Structure
Use the ls command to list files and directories in a given location.
ls /
- Moving Between Directories
Use the change directory (cd) command to move between the directories. For example if you need to move to the home directory:
Examples:
- Move to the home directory:
cd ~ - Navigate to the root directory (/):
cd / - Move to the etc directory:
cd /etc - Go back one directory up:
cd .. - Return to the previous directory:
cd –
- Viewing Directory Contents
- List all files and directories:
ls - List files with detailed information (permissions, size, owner, etc.):
ls -l - Show hidden files (files starting with .):
ls -a
- Finding Your Current Location
Use the pwd (Print Working Directory) command to see your current directory path:
pwd
- Searching for Files and Directories
- Find a file by name:
find / -name filename - Search for a specific file type (e.g., .txt files in /home):
find /home -type f -name “*.txt” - Locate a command or file using which or whereis:
which python
whereis nano
- Viewing File and Directory Details
- Display details of a specific file:
stat filename - Show disk usage of a file or directory:
du -sh /var/log - Check available disk space:
df -h
- Navigating with Tab Completion
Use the Tab key for auto-completing filenames or commands. Example: Type cd /us and press Tab, it will autocomplete to /usr if available.
- Understanding Absolute vs. Relative Paths
- Absolute Path: Full path from / (root).
cd /home/user/Documents - Relative Path: Path from the current directory.
cd Documents
Practical Commands for Managing Directories
Command | Description | Example |
pwd | Displays the current working directory. | pwd |
ls | Lists files and directories in the current directory. | ls /home |
ls -l | Lists files with detailed information (permissions, owner, size, etc.). | ls -l /var/log |
ls -a | Lists all files, including hidden ones (starting with .). | ls -a /etc |
cd directory | Changes the current directory. | cd /home/user/Documents |
cd .. | Moves up one directory level. | cd .. |
cd – | Switches to the previous directory. | cd – |
mkdir directory | Creates a new directory. | mkdir new_folder |
mkdir -p parent/child | Creates nested directories (if parent doesn’t exist). | mkdir -p project/src |
rmdir directory | Removes an empty directory. | rmdir old_folder |
rm -r directory | Deletes a non-empty directory and its contents. | rm -r my_folder |
mv old new | Renames or moves a directory. | mv old_folder new_folder |
cp -r source destination | Copies a directory and its contents. | cp -r /etc /backup |
find /path -type d -name name | Finds a directory by name. | find /home -type d -name “Documents” |
du -sh directory | Shows the total size of a directory. | du -sh /var/log |
Conclusion: Why Understanding Linux Directories Matters
Understanding Linux directories is essential for efficient system navigation, security, and troubleshooting. Each directory has a specific role, from storing system files to managing user data. Knowing their structure improves workflow, access control, and system performance. Mastering directories helps in better file management and problem-solving.
Frequently Asked Questions
1. Can I delete files from /tmp
?
Yes, files in /tmp
are temporary and usually get deleted automatically on system reboot. However, manually removing unnecessary files can free up space.
2. What is the difference between /mnt
and /media
?
Both /mnt
and /media
are used for mounting external storage devices. /mnt
is traditionally used for manual mounts, while /media
is commonly used for automatic mounting of removable devices.
3. What is the Linux directory structure?
The Linux directory structure is a hierarchical system where all files and directories originate from the root directory (/
). It organizes files systematically for better management and functionality.