Table of Contents
1. /bin and /sbin : Basic command storage location
2. /usr : The "main battlefield" of user programs
3. /etc : Home of configuration files
4. /var : Store variable data
5. /home and /root : the user's personal space
6. /tmp and /run : the storage place for temporary files
7. /dev , /proc , /sys : Special file system
8. /lib and /lib64 : The system startup dependency library
9. /opt and /srv : optional with service data
Summary: The core idea of FHS
Home System Tutorial LINUX Understanding the Linux Filesystem Hierarchy Standard (FHS)

Understanding the Linux Filesystem Hierarchy Standard (FHS)

Aug 06, 2025 pm 04:23 PM
linux File system

/bin and /sbin store basic commands and system management commands; 2. /usr stores user programs and related resources; 3. /etc is the configuration file directory; 4. /var stores variable data such as logs and caches; 5. /home and /root are the home directories of ordinary users and root users; 6. /tmp and /run are used for temporary files and runtime data; 7. /dev, /proc, /sys provides device and system information interfaces; 8. /lib and /lib64 contain library files required for system startup; 9. /opt and /srv are used for third-party software and service data respectively; FHS improves system management efficiency through standardized directory structure, making the layout of Linux files clear and consistent, making it easy to maintain and cross-platform collaboration.

Understanding the Linux Filesystem Hierarchy Standard (FHS)

The file structure in Linux systems is not arranged at will, but follows a unified standard - Filesystem Hierarchy Standard (FHS) . This standard defines the purpose of each directory and what types of files should be stored. Understanding FHS will not only help you manage your Linux system more efficiently, but will also make you more comfortable when troubleshooting problems, writing scripts, or deploying applications.

Understanding the Linux Filesystem Hierarchy Standard (FHS)

The following is a popular analysis of the FHS core directory, which is suitable for beginners and intermediate users to quickly master.


1. /bin and /sbin : Basic command storage location

  • /bin : stores basic executable commands that can be used by all users, such as ls , cp , mv , rm , etc. These commands must also be available in single-user mode.
  • /sbin : Stores system management commands dedicated to system administrators , such as fdisk , ifconfig , reboot , etc. Normal users usually do not have permission to execute these commands.

? Small knowledge: In early systems, /bin and /sbin must be located in the root partition so that basic commands can be run normally during system maintenance.

Understanding the Linux Filesystem Hierarchy Standard (FHS)

2. /usr : The "main battlefield" of user programs

/usr is the abbreviation of "Unix System Resources", but it is not a place for users to store personal files, but rather a read-only user application and library files . It can be understood as "Program Files" in Windows.

Key subdirectories include:

Understanding the Linux Filesystem Hierarchy Standard (FHS)
  • /usr/bin : Most user commands (such as python , gcc , wget )
  • /usr/sbin : non-critical system management commands (such as httpd , sshd )
  • /usr/lib : The library file that the program depends on
  • /usr/share : Schema-independent data, such as documents, icons, help files
  • /usr/local : Locally installed software , usually manually compiled and installed by the administrator to avoid conflicts with the system package manager

⚠️ Note: The content under /usr is usually read-only and is only mounted after the system is started and is not used to store variable data.


3. /etc : Home of configuration files

All system and application configuration files are placed in /etc . for example:

  • /etc/passwd : User account information
  • /etc/fstab : Disk mount configuration
  • /etc/ssh/sshd_config : SSH service configuration

Although modern systems have also started using configurations outside /etc (such as /usr/lib/systemd for systemd), the main configuration is still here.

✅ Best practice: Backup before modifying the configuration, such as sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak


4. /var : Store variable data

/var is the abbreviation of "variable", which is used to store files that are constantly changing at runtime , such as logs, caches, mail queues, etc.

Common subdirectories:

  • /var/log : System and application logs (such as syslog , auth.log )
  • /var/cache : program caches data (such as apt 's package cache)
  • /var/spool : tasks waiting to be processed (such as print queues, cron tasks)
  • /var/lib : status information of the database or package manager (such as dpkg , docker )

? Why is it important? The log file is here. The first thing you need to look at when troubleshooting problems is /var/log .


5. /home and /root : the user's personal space

  • /home : The home directory of ordinary users, such as /home/alice , which stores personal documents, configuration files (hidden files starting with . ), etc.
  • /root : The root user's home directory is not under /home , for security reasons.

? Security tips: The /root directory permissions are strictly restricted and cannot be accessed by ordinary users.


6. /tmp and /run : the storage place for temporary files

  • /tmp : Temporary file , which can be written by any user, and is usually cleared after the system restarts.
  • /run : Stores temporary data when the system is started , such as process ID file ( .pid ) and socket file.

? Example: /run/sshd.pid records the process ID of the SSH service, making it easier to manage services.


7. /dev , /proc , /sys : Special file system

These directories do not store real files, but interfaces to the kernel and device:

  • /dev : Device files , such as /dev/sda (hard disk), /dev/tty (terminal). Linux operates hardware as a file.
  • /proc : Virtual file system for process and system information , such as /proc/cpuinfo , /proc/meminfo . Each process also has a directory named after the PID.
  • /sys : a virtual file system for system devices and driver information , used to configure kernel parameters and support udev device management.

? Practical tips: cat /proc/loadavg can view system load.


8. /lib and /lib64 : The system startup dependency library

  • /lib : Stores shared libraries and kernel modules required by /bin and /sbin .
  • /lib64 : Library files for 64-bit systems (common on 64-bit systems).

⚙️ Importance: If these libraries are corrupted, the system may not start.


9. /opt and /srv : optional with service data

  • /opt : Optional third-party software packages , such as certain commercial software (such as Google Chrome, MATLAB) will be installed here.
  • /srv : Service-related data , such as website content ( /srv/www ), FTP files ( /srv/ftp ), but it is less used, and many people still use /var/www .

Summary: The core idea of FHS

The purpose of FHS is to standardize the directory structure , keep different Linux distributions consistent, and facilitate software packaging, system maintenance and cross-platform collaboration.

Although modern Linux has evolved in details (such as systemd affects the use of /run ), FHS is still the cornerstone of understanding Linux system layout.

Basically that's it. Master the purpose of these directories and you will not get lost when you "find files" or "installed software" in Linux.

The above is the detailed content of Understanding the Linux Filesystem Hierarchy Standard (FHS). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1582
276
How to make PHP container support automatic construction? Continuously integrated CI configuration method of PHP environment How to make PHP container support automatic construction? Continuously integrated CI configuration method of PHP environment Jul 25, 2025 pm 08:54 PM

To enable PHP containers to support automatic construction, the core lies in configuring the continuous integration (CI) process. 1. Use Dockerfile to define the PHP environment, including basic image, extension installation, dependency management and permission settings; 2. Configure CI/CD tools such as GitLabCI, and define the build, test and deployment stages through the .gitlab-ci.yml file to achieve automatic construction, testing and deployment; 3. Integrate test frameworks such as PHPUnit to ensure that tests are automatically run after code changes; 4. Use automated deployment strategies such as Kubernetes to define deployment configuration through the deployment.yaml file; 5. Optimize Dockerfile and adopt multi-stage construction

How to build an independent PHP task container environment. How to configure the container for running PHP timed scripts How to build an independent PHP task container environment. How to configure the container for running PHP timed scripts Jul 25, 2025 pm 07:27 PM

Building an independent PHP task container environment can be implemented through Docker. The specific steps are as follows: 1. Install Docker and DockerCompose as the basis; 2. Create an independent directory to store Dockerfile and crontab files; 3. Write Dockerfile to define the PHPCLI environment and install cron and necessary extensions; 4. Write a crontab file to define timing tasks; 5. Write a docker-compose.yml mount script directory and configure environment variables; 6. Start the container and verify the log. Compared with performing timing tasks in web containers, independent containers have the advantages of resource isolation, pure environment, strong stability, and easy expansion. To ensure logging and error capture

How to Securely Erase a Hard Drive on Linux How to Securely Erase a Hard Drive on Linux Jul 24, 2025 am 12:08 AM

Confirm the target hard disk device name (such as /dev/sda) to avoid accidentally deleting the system disk; 2. Use sudoddif=/dev/zeroof=/dev/sdXbs=1Mstatus=progress to overwrite the zero value in full disk, which is suitable for most scenarios; 3. Use sudoshred-v-n3/dev/sdX for three random data overwrites to ensure that it cannot be restored; 4. Optionally execute sudobadblocks-wsv/dev/sdX for destructive write tests; finally use sudohexdump-C/dev/sdX|head to verify whether it is all zero and complete safe erasing.

Linux vs Windows: Which Operating System is Better for You? Linux vs Windows: Which Operating System is Better for You? Jul 29, 2025 am 03:40 AM

Windowsisbetterforbeginnersduetoeaseofuse,seamlesshardwarecompatibility,andsupportformainstreamsoftwarelikeMicrosoftOfficeandAdobeapps.2.LinuxoutperformsWindowsonolderorlow-resourcehardwarewithfasterboottimes,lowersystemrequirements,andlessbloat.3.Li

How to Schedule Tasks on Linux with Cron and anacron How to Schedule Tasks on Linux with Cron and anacron Aug 01, 2025 am 06:11 AM

cronisusedforpreciseschedulingonalways-onsystems,whileanacronensuresperiodictasksrunonsystemsthataren'tcontinuouslypowered,suchaslaptops;1.Usecronforexacttiming(e.g.,3AMdaily)viacrontab-ewithsyntaxMINHOURDOMMONDOWCOMMAND;2.Useanacronfordaily,weekly,o

What to do after installing linux What to do after installing linux Jul 23, 2025 am 02:57 AM

AfterinstallingLinux,thefirststepsincludeupdatingyoursystem,installingessentialsoftware,settingupbackupandsecuritymeasures,andcustomizingtheinterfacetosuityourpreferences.1)Updateyoursystemusingtheappropriatecommandforyourdistro(e.g.,sudoaptupdate&am

How to install software on Linux using the terminal? How to install software on Linux using the terminal? Aug 02, 2025 pm 12:58 PM

There are three main ways to install software on Linux: 1. Use a package manager, such as apt, dnf or pacman, and then execute the install command after updating the source, such as sudoaptininstallcurl; 2. For .deb or .rpm files, use dpkg or rpm commands to install, and repair dependencies when needed; 3. Use snap or flatpak to install applications across platforms, such as sudosnapinstall software name, which is suitable for users who are pursuing version updates. It is recommended to use the system's own package manager for better compatibility and performance.

The Ultimate Guide to High-Performance Gaming on Linux The Ultimate Guide to High-Performance Gaming on Linux Aug 03, 2025 am 05:51 AM

ChoosePop!_OS,Ubuntu,NobaraLinux,orArchLinuxforoptimalgamingperformancewithminimaloverhead.2.InstallofficialNVIDIAproprietarydriversforNVIDIAGPUs,ensureup-to-dateMesaandkernelversionsforAMDandIntelGPUs.3.EnabletheperformanceCPUgovernor,usealow-latenc

See all articles