Because there are so many teams that use Linux to develop products or distribution, if everyone uses their own ideas to configure a directory for file placement, it can cause a lot of management problems. As a result, the Filesystem Hierarchy Standard (FHS) was later released.
The main goal, according to FHS's official documents, is to let users know where the data is usually placed. In other words, the focus of FHS is to standardize what data should be placed in each particular directory.
FHS defines the directory as a four interactive form depending on whether the file system is frequently used or not and if the user is arbitrarily changing it:
shareable: A directory that can be shared with other system mounts, so it includes data such as executing files and users ' messages, and is a directory that can be shared with other hosts on the network for mounting.
Not to be shared : device files running on their own machines or socket files related to the program, etc., are not suitable for sharing with other hosts because they are only relevant to their machines.
constant: Some data does not change frequently, only changes with the system version. Examples include function libraries, description files, host service profiles managed by system administrators, and so on.
variable : frequently changing data, such as login files, user files, etc.
root directory (/)
The root directory is the most important directory of the whole system, because not only all the directories are derived from the root directory, but also the root directory with the boot, restore, system repair and other operations.
Therefore, the FHS standard recommendation: The root directory (/) should be the smaller the partition should be the better, and the software installed by the application should not be placed in the same partition with the root directory, keep the root directory as small as possible. This is not only good performance, the root directory is located in the file system is also less prone to problems.
Execute file directory (/bin)
The system has a lot of directories for executing files, but/bin is more special. Because /bin places commands that can be manipulated in single-user maintenance mode . In/bin the following commands can be used by root and general account, mainly with Cat,chmod,chown,date,mv,mkdir,cp,bash and other commonly used commands.
Boot file directory (/boot)
This directory mainly places the files that will be used to boot, including the Linux kernel files and the boot menu and the required configuration files .
Drive device catalog (/dev)
On Linux systems, any device and interface device exists in this directory in the form of files . You simply access a device by accessing one of the files under this directory. The more important documents are/dev/null,/dev/zero,/dev/tty and so on.
Configuration file directory (/etc)
Most of the system configuration files are placed in this directory, such as the person's account password file, the various service start files, etc. In general, the individual file attributes in this directory are accessible to the general user, but only root has the right to modify. The more important documents are/etc/init.d,/etc/inittab,/etc/sysconfig and so on.
User home folder (/*)
This is the system default User home folder (home directory). When you create a general user account, the default User home folder will be normalized here. ~ Represents the home folder of the current user .
system function library (/lib)
There are a lot of libraries in the system, and/lib places the library of functions that will be used at boot time, as well as the function libraries that the commands under/bin or/sbin call.
* You can think of the function library as a "plug-in", some commands must have these "plug-in" to be able to successfully complete the implementation of the program meaning.
Media device suspend zone (/media)
Media is the "medium" in English, as the name implies, this/media is placed below is a removable device. devices, including floppy disks, CDs, DVDs, and so on, are temporarily mounted here. The common filenames are/media/floppy,/media/cdrom and so on.
Additional device suspend area (/MNT)
If you want to temporarily mount some additional devices, it is generally recommended that you place them in this directory. In earlier times, this directory was used in the same way as/media. Just after the/media, this directory is used for temporary loading.
Third-party Software installation directory (/OPT)
This directory is used to install third-party applications, and can be specified by the user at the installation location. When you need to uninstall a third-party application, you can delete the installation directory directly without affecting any other system settings.
Administrator home folder (/root)
The home folder of the system administrator (root). The reason for this is that if you go into single-user maintenance mode and only mount the root directory, that directory will be able to have the root home folder, so we would like Root's home folder and root directory to be placed in the same partition.
Important System Execution files (/sbin)
Linux has a lot of commands to set up the system environment, these commands only root can use to "set up" the system, other users can only be used to "query" only. Placed under the/sbin for the boot process required, which includes the boot, repair, restore the system required by the command.
Service Data storage directory (/SRV)
SRV can be considered an abbreviation for "service", which is the data directory to be used by some network services after they are started . Common services such as WWW, FTP, and so on. For example, the Web page data required by the WWW service can be placed in the/srv/www/.
Temporary file storage directory (/tmp)
This is where the general user or the executing program temporarily places the file. This directory is accessible to anyone, so you need to clean it up regularly. Of course, important data cannot be placed in this directory because the system will not periodically delete all data from the/tmp directory .
Missing content repair directory (/lost+found)
This directory is a directory that is generated using the standard EXT2/EXT3 file system format, which is equivalent to placing some missing fragments in this directory when a file system error occurs . This directory usually exists at the top level of the partition.
Virtual file system directory (/PROC)
The directory itself is a virtual file system (Vsan filesystem). It places data in memory, such as the system kernel, processes, external devices, and network status. because the data in this directory is in memory, it does not account for any hard disk space .
Virtual file system directory (/sys)
This directory is very similar to/proc, but also a virtual file system, which is also a key to recording kernel-related information . This includes the kernel modules currently loaded and the hardware device information detected by the kernel. This directory also does not account for hard disk capacity.
System Software Resource directory (/usr)
Many small white will mistakenly think that/usr is the user's abbreviation, in fact, USR is a UNIX software Resource abbreviation, that is, "UNIX operating system software resources " placed in the directory, rather than the user's data, this needs to be noted.
FHS recommends that all software developers should place their data appropriately in subdirectories under this directory, rather than creating a separate directory of the software themselves.
/usr/bin/: Most of the users can use the command to put it here
/usr/include/: Header and include file (include) placement for program languages such as C + +
/usr/lib/: A library of functions, a target file, and some executable files or scripts that are not commonly used by the user
/usr/local/: The system administrator installs the downloaded software on the local computer and recommends installing to this directory
/usr/sbin/: System commands required for non-system uptime
/usr/share/: Where to place shared files
/usr/src/: General source code recommended to be placed here
Normal variable file directory (/var)
This directory is intended for normal, volatile files, including cache, login files (log file), and files generated by some software operations, including program files (lock file, run file), or files such as MySQL databases.
If/usr is a directory that occupies a larger hard disk capacity during installation,/var is a directory that will gradually take up hard disk capacity after the system is running.
/var/cache/: Some of the staging files that are generated during the run of the application itself
/var/lib/: The program itself executes the process that needs to be used to the data files placed in the directory
/var/lock/: File resources under the directory can only be used by one application at a time
/var/log/: directory where login files are placed
/var/mail/: The directory where personal e-mail is placed
/var/run/: Some programs or services after the startup of the PID directory
/var/spool/: Putting data queued for use by other application programs
Linux Standard directory Structure FHS