When working with Linux, understanding the Filesystem Hierarchy Standard (FHS) is essential. Unlike Windows, which divides data into multiple drives (C:, D:, etc.), Linux follows a structured, single-rooted system. Letβs explore its core directories and their significance!
π± The Root Directory (/) β The Foundation of Linux
At the top of the hierarchy is /
, the root directory. Every file and directory in Linux originates from this point. It contains all essential system directories, configuration files, and user data.
Everything in Linux is a file, whether it's a text document, a directory, a hardware device, or a running process.
π Key Directories in Linux
1οΈβ£ /bin β Essential User Binaries π»
- Stores essential system executables required for basic operations and booting.
- Available for all users, even in single-user mode.
-
Examples:
ls
,cp
,mv
,grep
,cat
,echo
,rm
.
2οΈβ£ /sbin β System Binaries π§
- Contains administrative commands for system management.
- Requires root privileges to execute most commands.
-
Examples:
shutdown
,reboot
,fsck
,fdisk
,iptables
,mkfs
.
3οΈβ£ /etc β Configuration Files βοΈ
- Houses system-wide configuration files and scripts.
- Modifying files here requires administrative privileges.
-
Examples:
-
/etc/fstab
β Defines filesystem mount points. -
/etc/passwd
β Stores user account information. -
/etc/hostname
β Defines the system hostname. -
/etc/network/interfaces
β Manages network configurations.
-
4οΈβ£ /home β User Home Directories π
- Stores personal directories for each user.
- Each user gets their own space:
/home/username/
. - Contains:
-
Documents
π -
Downloads
π₯ -
Pictures
πΌοΈ -
Videos
π₯ -
.bashrc
(custom shell configurations).
-
5οΈβ£ /root β Root Userβs Home Directory π³
- Dedicated home directory for the superuser (root).
- Provides a secure workspace, separate from standard user directories.
β οΈ Never use root for daily tasks!
6οΈβ£ /var β Variable Data π
- Stores frequently changing files, such as logs, mail, and databases.
-
Examples:
-
/var/log/
β System and application logs π. -
/var/spool/
β Mail queue & printer jobs π©π¨οΈ. -
/var/cache/
β Temporary application cache data β‘.
-
7οΈβ£ /tmp β Temporary Files ποΈ
- Stores temporary files created by applications and the system.
- Often cleared automatically on reboot.
8οΈβ£ /usr β User Applications & Libraries π
A large directory divided into subdirectories:
-
/usr/bin/
β Common user applications (e.g.,vim
,nano
,wget
). -
/usr/sbin/
β System administration binaries (e.g.,apachectl
). -
/usr/local/
β Manually installed software.
9οΈβ£ /lib & /lib64 β System Libraries π¦
- Holds shared libraries (
.so
files) required by binaries in/bin
and/sbin
. -
Examples:
-
/lib/x86_64-linux-gnu/libc.so.6
β Standard C library. -
/lib/modules/
β Kernel modules and drivers.
-
π /opt β Optional Software π
- Used for third-party or manually installed software.
- Common for commercial apps like Google Chrome, Oracle Java, and proprietary drivers.
1οΈβ£1οΈβ£ /mnt & /media β Mount Points π₯οΈ
- /mnt/ β Temporary mount point for system administrators.
- /media/ β Auto-mounted external devices like USBs, CDs, and SD cards.
1οΈβ£2οΈβ£ /dev β Device Files π
- Special files representing hardware devices.
-
Examples:
-
/dev/sda
β First hard drive. πΎ -
/dev/null
β Discard anything written to it. ποΈ -
/dev/random
β Generates random data. π²
-
1οΈβ£3οΈβ£ /proc & /sys β Kernel & Process Information π§
-
/proc/ β A virtual file system with real-time system information.
- Examples:
-
/proc/cpuinfo
β CPU details. π₯οΈ -
/proc/meminfo
β Memory usage. πΎ -
/proc/[PID]
β Process details.
- /sys/ β Exposes kernel and hardware configurations.
1οΈβ£4οΈβ£ /run β Runtime Data β‘
- Stores system-wide runtime data (e.g., PIDs, sockets).
- Data here is deleted on reboot.
1οΈβ£5οΈβ£ /srv β Service Data ποΈ
- Stores data for system services (e.g., web servers, FTP).
- Example:
/srv/http/
for a web serverβs root directory.
1οΈβ£6οΈβ£ /lost+found β Recovered Files π οΈ
- Used by the
fsck
utility for recovering lost files. - Appears in each partition with a Linux filesystem.
π― Why Understanding the Linux Filesystem Matters?
β
Better system navigation β Move around efficiently.
β
Enhanced troubleshooting skills β Fix errors quickly.
β
Security awareness β Prevent unauthorized modifications.
β
Performance optimization β Manage resources effectively.
π Conclusion π―
The Linux file system is structured for organization, security, and efficiency. Whether you're a beginner or an expert, mastering this hierarchy will make you a better Linux user!
π οΈ Keep exploring, keep learning! π
Top comments (6)
Great article! This deep dive into the Linux file hierarchy really clarifies how everything is organized. I especially appreciate the explanations of the less common directories like /proc and /sys. It's much easier to navigate and troubleshoot now. Thanks for sharing this valuable resource!
Looking to optimize your business processes? Hire skilled Odoo programmers to customize and develop your Odoo ERP solution. They can tailor the platform to your specific workflows, integrate essential modules, and create custom functionalities. Finding the right Odoo developers is crucial for maximizing your ROI and achieving seamless operations. Elevate your business with a perfectly tailored Odoo system.
Thank you. I learned something here!
Nice one...
Nice
Very nice!
Thanks for your teaching. It benefits me. In your article, I quite agree with the sentence "Keep exploring, keep learning!"
Some comments may only be visible to logged-in visitors. Sign in to view all comments.