A Deep Dive into the Linux Filesystem Hierarchy Standard
Jul 25, 2025 am 03:43 AMLinux uses the Filesystem Hierarchy Standard (FHS) to organize directories systematically, ensuring consistency across distributions; 2. Key directories include /bin for essential user binaries like ls and bash, critical for early boot; 3. /sbin contains system administration tools such as fdisk and iptables, typically used by root; 4. /usr holds user-facing software and resources in subdirectories like /usr/bin, /usr/sbin, /usr/lib, /usr/share, and /usr/local for locally compiled programs; 5. /etc stores system-wide configuration files such as /etc/passwd and /etc/fstab; 6. /var contains variable data including logs in /var/log, caches in /var/cache, spools in /var/spool, runtime data in /var/run (a symlink to /run), and application state in /var/lib; 7. /tmp is for temporary files cleared on reboot, while /var/tmp stores temporary data that may survive reboots; 8. /dev contains device files representing hardware like /dev/sda and special devices like /dev/null; 9. /proc and /sys are virtual filesystems providing kernel and hardware information through memory-mapped interfaces; 10. /home holds personal user directories with configurations and files, while /root is the dedicated home for the root user; 11. /run stores runtime data such as PID and socket files, mounted in memory for speed and cleared at reboot; 12. /boot contains bootloader files, kernel (vmlinuz), and initramfs needed before root filesystem mounts; 13. /lib and /lib64 store essential shared libraries required by /bin and /sbin for system boot; 14. /opt is for optional third-party software like Google Chrome, often self-contained in its own subdirectory; 15. /mnt is for temporary manual mounts, and /media for automatically mounted removable media like USB drives; understanding the FHS enables efficient system management, scripting, and troubleshooting by clarifying the purpose and location of each directory.
Linux doesn’t just throw files anywhere—it follows a well-defined structure called the Filesystem Hierarchy Standard (FHS). This standard ensures consistency across distributions, making it easier for admins, developers, and scripts to know where things should be. Whether you're troubleshooting, writing a script, or just trying to understand where logs go, knowing the FHS is essential.

Here’s a practical breakdown of the key directories and what they’re for.
/bin – Essential User Binaries
This is where fundamental command-line tools live—programs you absolutely need to get basic work done, even in single-user mode.

- Examples:
ls
,cp
,mv
,bash
,grep
- These binaries are available early in the boot process.
-
/bin
is usually a symbolic link to/usr/bin
on modern systems (thanks to the usrs merge).
? Why it matters: If your system boots without
/usr
,/bin
must still work. That’s why only critical tools go here.
/sbin – System Administration Binaries
Like /bin
, but for system-level commands—tools typically used by root or with elevated privileges.

- Examples:
fdisk
,iptables
,reboot
,ifconfig
- Not usually in a regular user’s
PATH
- Often symlinked to
/usr/sbin
on newer systems
These are the tools that keep the system running, not the ones you use daily for file manipulation.
/usr – User Resources (but not just for users)
Despite the name, /usr
isn’t for home directories. It’s a read-only hierarchy containing most of the system’s user-facing software and data.
Think of it as the "applications and shared resources" directory.
Subdirectories you’ll see:
-
/usr/bin
– Most user commands -
/usr/sbin
– Non-essential system binaries (likehttpd
,sshd
) -
/usr/lib
– Libraries for/usr/bin
and/usr/sbin
-
/usr/share
– Architecture-independent data (docs, icons, man pages) -
/usr/local
– Locally compiled software (not managed by package manager)
? Fun fact:
/usr
used to mean "user" as in user-installed programs, but now it's more of a historical artifact. On many systems,/usr
is mounted read-only.
/etc – Configuration Central
All system-wide configuration files live here. No binaries, no data—just config.
-
/etc/passwd
,/etc/fstab
,/etc/ssh/sshd_config
- Host-specific: settings that don’t change when you swap drives or reinstall
- Package managers drop config files here during installation
?? Rule of thumb: If a program needs a system-wide setting, it’s probably in
/etc
.
/var – Variable Data
Files that change during system operation go here. Think logs, caches, spools, and transient data.
Common subdirectories:
-
/var/log
– Log files (e.g.,syslog
,auth.log
) -
/var/cache
– Cached data (e.g., package managers store.deb
or.rpm
files here) -
/var/spool
– Queued tasks (print jobs, cron, mail) -
/var/run
– Runtime variable data (often a symlink to/run
) -
/var/lib
– Persistent data for applications (e.g., databases, package managers)
?
/var
grows over time—this is often the partition you monitor for disk usage.
/tmp and /var/tmp – Temporary Files
Both are for temporary storage, but with differences:
-
/tmp
– Wiped on reboot (usually mounted astmpfs
in RAM) -
/var/tmp
– Meant for files that survive reboots (but still not guaranteed long-term)
Permissions are tightly controlled—modern systems use sticky bits
so users can’t delete each other’s temp files.
/dev – Device Files
Linux treats hardware as files. This directory contains device nodes that represent physical or virtual devices.
-
/dev/sda
– First SATA/SSD drive -
/dev/ttyUSB0
– USB-to-serial adapter -
/dev/null
– Black hole (discards everything written to it) -
/dev/zero
– Infinite source of zeros
Most of these are managed by udev
dynamically as devices are detected.
/proc and /sys – Virtual Filesystems
These aren’t real files on disk. They’re interfaces to kernel data structures.
/proc – Process and system info
-
/proc/cpuinfo
,/proc/meminfo
– Hardware details -
/proc/[PID]
– Runtime info about running processes - Originally for processes, now also used for system settings
/sys – Device and driver hierarchy (sysfs)
- Exposes kernel objects like devices, drivers, and class info
- Used for configuring hardware parameters at runtime
- Key for tools like
udev
? Both are in memory (
procfs
andsysfs
) and vanish when unmounted.
/home – User Home Directories
Each user gets a personal space here (e.g., /home/alice
). Contains:
- Personal files (Documents, Downloads)
- Hidden config files (
.bashrc
,.ssh/
) - Usually not shared across machines (unlike
/usr
or/etc
)
In enterprise setups, this might be on a network share (NFS).
/root – Home Directory for Root
Not /home/root
. The root user’s home is directly under /root
. Keeps it accessible even if /home
is on a separate partition that fails to mount.
/run – Runtime Data
A relatively recent addition (replacing parts of /var/run
). Stores transient files that need to persist only while the system is running.
- PID files (e.g.,
/run/sshd.pid
) - Lock files
- Socket files
- Mounted as
tmpfs
, so it’s fast and cleared on reboot
Ensures clean state on startup.
/boot – Bootloader and Kernel Files
Contains everything the system needs to boot before the root filesystem is available.
-
/boot/vmlinuz
– The kernel -
/boot/initramfs
– Initial RAM disk -
/boot/grub/
or/boot/efi/
– Bootloader files
This can be a separate partition to ensure early boot components are accessible.
/lib and /lib64 – Essential Libraries
These hold shared libraries needed by /bin
and /sbin
.
-
/lib
– 32-bit libraries (even on 64-bit systems, for compatibility) -
/lib64
– 64-bit libraries on 64-bit systems - Includes
libc
,ld-linux.so
(the dynamic linker)
Like binaries in /bin
, these are critical for early boot.
/opt – Optional Application Software
Used for installing third-party or proprietary software that doesn’t integrate with the standard hierarchy.
- Common for self-contained apps (e.g., Google Chrome, some Java apps)
- Each app typically lives in
/opt/<appname></appname>
- Often includes its own
bin
,lib
,etc
under that directory
Less common now with containers and package managers, but still used.
/mnt and /media – Mount Points
-
/mnt
– Temporary manual mounts (e.g.,mount /dev/sdb1 /mnt/backup
) -
/media
– Removable media (automatically mounted—USB drives, CDs)
Distros handle these differently, but both are just conventional places to attach filesystems.
Final Notes
The FHS isn’t just tradition—it’s practical. It helps:
- Automate system management
- Write portable scripts
- Troubleshoot faster
- Separate state from code
While some directories (like /bin
→ /usr/bin
) have evolved due to the usrs merge, the logic remains: separation of concerns.
Understanding the FHS doesn’t require memorizing every path—but knowing the purpose behind each major directory makes Linux less mysterious.
Basically, if you know where to look, the system tells you how it works.
The above is the detailed content of A Deep Dive into the Linux Filesystem Hierarchy Standard. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

LXD is described as the next-generation container and virtual machine manager that offers an immersive for Linux systems running inside containers or as virtual machines. It provides images for an inordinate number of Linux distributions with support

When encountering DNS problems, first check the /etc/resolv.conf file to see if the correct nameserver is configured; secondly, you can manually add public DNS such as 8.8.8.8 for testing; then use nslookup and dig commands to verify whether DNS resolution is normal. If these tools are not installed, you can first install the dnsutils or bind-utils package; then check the systemd-resolved service status and configuration file /etc/systemd/resolved.conf, and set DNS and FallbackDNS as needed and restart the service; finally check the network interface status and firewall rules, confirm that port 53 is not

If you find that the server is running slowly or the memory usage is too high, you should check the cause before operating. First, you need to check the system resource usage, use top, htop, free-h, iostat, ss-antp and other commands to check CPU, memory, disk I/O and network connections; secondly, analyze specific process problems, and track the behavior of high-occupancy processes through tools such as ps, jstack, strace; then check logs and monitoring data, view OOM records, exception requests, slow queries and other clues; finally, targeted processing is carried out based on common reasons such as memory leaks, connection pool exhaustion, cache failure storms, and timing task conflicts, optimize code logic, set up a timeout retry mechanism, add current limit fuses, and regularly pressure measurement and evaluation resources.

As a system administrator, you may find yourself (today or in the future) working in an environment where Windows and Linux coexist. It is no secret that some big companies prefer (or have to) run some of their production services in Windows boxes an

Frankly speaking, I cannot recall the last time I used a PC with a CD/DVD drive. This is thanks to the ever-evolving tech industry which has seen optical disks replaced by USB drives and other smaller and compact storage media that offer more storage

In Linux systems, 1. Use ipa or hostname-I command to view private IP; 2. Use curlifconfig.me or curlipinfo.io/ip to obtain public IP; 3. The desktop version can view private IP through system settings, and the browser can access specific websites to view public IP; 4. Common commands can be set as aliases for quick call. These methods are simple and practical, suitable for IP viewing needs in different scenarios.

Built on Chrome’s V8 engine, Node.JS is an open-source, event-driven JavaScript runtime environment crafted for building scalable applications and backend APIs. NodeJS is known for being lightweight and efficient due to its non-blocking I/O model and

Data replication is the process of copying your data across multiple servers to improve data availability and enhance the reliability and performance of an application. In MySQL replication, data is copied from a database from the master server to ot
