The Hierarchical Tree Structure in Linux File System - snir1551/DevOps-Linux GitHub Wiki
The Hierarchical Tree Structure in Linux File System
The Linux file system is organized as a single hierarchical tree, where:
- The root of the tree is represented by /.
- Every file, directory, device, and resource is located somewhere within this tree.
- Each item in the system has a unique path starting from / that identifies its location.
This structure allows Linux to maintain a clear, organized, and scalable file system, where everything is part of a single, unified directory tree.
/
βββ bin/
βββ boot/
βββ dev/
βββ etc/
βββ home/
β βββ user1/
β βββ user2/
β βββ ...
βββ lib/
βββ media/
βββ mnt/
βββ opt/
βββ proc/
βββ root/
βββ sbin/
βββ tmp/
βββ usr/
βββ var/
-
Absolute Path:
- Always starts from /
- Describes the complete location of a file or directory in the system.
- Examples:
- /etc/passwd
- /home/user1/documents/resume.pdf
-
Relative Path:
- Starts from the current working directory.
- For example, if you are in /home/user1 and want to access documents/resume.pdf, you can reference it as:
- documents/resume.pdf
The file system resembles an inverted tree:
- The root (/) is the top of the tree.
- Directories branch out from the root (branches), and files are like leaves.
Key Directories in the Linux File System
The Linux file system is organized in a standardized way. Each major directory has a specific purpose. Hereβs an overview of the most important directories:
-
/ β Root Directory
- The starting point of the file system hierarchy. Everything in the system is organized under this directory.
-
/bin β Essential User Binaries
-
Contains essential command-line binaries (programs) that are required for basic system functionality. Examples: ls, cp, mv, bash, cat.
-
/sbin β System Binaries
- Contains system administration binaries that are typically used by the system or by the root user. Examples: fsck, reboot, ifconfig.
-
/etc β Configuration Files
- Contains system-wide configuration files and scripts. Examples:
- /etc/passwd β User account information.
- /etc/fstab β Filesystem mount points.
- Contains system-wide configuration files and scripts. Examples:
-
/home β User Home Directories
- Contains personal directories for each user. For example: /home/user1/ , /home/user2/
- Each userβs files, configurations, and data are stored here.
-
/root β Root User Home Directory
- The home directory for the root user (system administrator).
- Equivalent to /home/root for the superuser.
-
/var β Variable Files
- Contains files that are expected to grow, such as:
- Logs (/var/log).
- Spools (/var/spool).
- Temporary mail files, caches, etc.
- Contains files that are expected to grow, such as:
-
/usr β User Programs and Data
- Contains user-installed programs and their data. Subdirectories include:
- /usr/bin β Non-essential user binaries.
- /usr/lib β Libraries.
- /usr/share β Shared data like documentation, icons, and locale files.
- /usr/include β Header files for development (e.g., C libraries).
- Contains user-installed programs and their data. Subdirectories include:
-
/lib β Essential Shared Libraries
- Contains shared libraries needed for programs in /bin and /sbin to run.
- For example: libc.so.6.
- Contains shared libraries needed for programs in /bin and /sbin to run.
-
/dev β Device Files
- Contains files that represent devices on the system (everything is a file in Linux). Examples:
- /dev/sda β Hard disk.
- /dev/tty β Terminals.
- /dev/null β Discard output.
- Contains files that represent devices on the system (everything is a file in Linux). Examples:
-
/proc β Virtual Filesystem for Process and Kernel Information
- A pseudo-filesystem that provides dynamic information about running processes and the kernel. Examples:
- /proc/cpuinfo
- /proc/meminfo
- /proc/1234/ (information about process with PID 1234).
- A pseudo-filesystem that provides dynamic information about running processes and the kernel. Examples:
-
/tmp β Temporary Files
- Used for storing temporary files created by users or applications. Files here are usually deleted upon system reboot.
-
/media and /mnt β Mount Points
- /media β Mount points for removable devices (e.g., USB drives, CD-ROMs).
- /mnt β A general mount point for mounting temporary filesystems.
-
/opt β Optional Software
- Used for installing add-on application software packages.
Directory | Purpose |
---|---|
/ |
Root directory β top of the file system hierarchy. |
/bin |
Essential binaries for all users. |
/sbin |
System binaries for administrative tasks. |
/etc |
Configuration files. |
/home |
User home directories. |
/root |
Root user's home directory. |
/var |
Variable data: logs, spools. |
/usr |
User programs and libraries. |
/lib |
Essential shared libraries. |
/dev |
Device files. |
/proc |
Process and kernel information. |
/tmp |
Temporary files. |
/media |
Mount points for removable media. |
/mnt |
Temporary mount point. |
/opt |
Optional software packages. |