For every Linux learner, understanding the directory structure of the Linux file system is a crucial step in learning Linux. The standard of the Linux file directory structure and the detailed functionality of each directory are important for us to use the Linux system. Let's start with the knowledge of the Linux directory structure.
When using Linux, if you pass Ls–l/you will find that a lot of directories, such as etc, USR, var, bin ... And so on, and in these directories, let's go inside and see that there are a lot of directories or files. The file system looks like a tree structure under Linux, so we can refer to the structure of the file system as a tree-shaped structure.
File systems are used to organize and arrange file access, so she is visible, in Linux, we can look at the structure of the LS and so on, in the Linux system, we see the tree structure, such as the operating system installed in a file system, he is represented by the/starting tree structure. The top of the Linux file system is/, we call it the Linux root, the Linux operating system file system. Linux File System portal is/, all directories, files, devices are/below,/is the Linux file system organizers, but also the most superior leader.
Because Linux is open source, the major companies and groups according to the core code of Linux to do their own operations, programming. This creates a difference in the directory under the root. This causes the individual to be unable to use other people's Linux system PC. Because you have no idea of some basic configuration, where the files are ... This creates confusion. This is why the FHS (filesystem hierarchy Standard) Institution was born. The agency is a voluntary group of Linux enthusiasts, mainly for Linux to do some basic requirements, not the operator to change a host to become the "illiterate" Linux.
According to FHS's official document, the main purpose of the http://www.pathname.com/fhs/is to let users know that the installed software is usually placed in that directory, so they want independent software developers, OS makers, and users who want to maintain the system are able to follow the FHS standards. In other words, the focus of FHS is to gauge what kind of data should be placed in each particular directory. This is a lot of benefit because the Linux operating system is able to develop the unique style that the developer wants in the same way as the directory architecture does.
In fact, FHS is based on the past experience has been a continuous revision, FHS based on the frequent use of file system and whether to allow users to change randomly, and the definition of the directory as four interactive form, with a table is a bit like the following:
Four types of:
1. Available for sharing:
Can be shared with other systems to mount the use of the directory, so including the execution of files and users of the mail and other data, is able to share to other hosts on the network mount the directory;
2. Not to be shared:
The device files that are operating on the machine or the socket files related to the program are not suitable for sharing with other hosts because they are only related to their own machines.
3. Unchanged:
Some data do not change frequently, and follow distribution without change. For example, a function library, a file description file, a system administrator manages the host service configuration file, and so on;
4. Can be changed:
Frequently changed data such as login files, newsgroups that are acceptable to the general user, etc.
In fact, FHS only defines what data should be placed under the three-tier directory for the directory tree schema, respectively, for the three directories below:
/(Root, Root): connected with the boot system;
/usr (Unix software Resource): Related to Software installation/execution;
/var (variable): related to the process of system operation.
The meaning and content of the root directory (/):
The root directory is the most important directory for the entire system, because not only are all directories derived from the root directory, but the root directory is also associated with actions such as boot/restore/system repair. Since the system needs a specific boot software, core files, boot required programs, function libraries, and so on file data, if the system error, the root directory must also have to be able to repair the file system of the program to do. Because the root directory is so important, in terms of FHS requirements, he wants the root directory not to be placed in very large partitions, because the larger the partition you will put more data, so that the root directory where the partition may have more error opportunities.
Therefore, the FHS standard recommends that the root (/) partition should be as small as possible, and that the software installed by the application should not be placed in the same partition as the root directory, keeping the root directory as small as possible. This is not only a good performance, the root directory of the file system is also less prone to problems. To be blunt, the root directory is the same as the Windows C disk.
Based on the above reasons, FHS that the root directory (/) should contain the following subdirectories:
In addition to the contents of these directories, it is also important to note that, because the root directory is connected to the boot, only the root directory will be mounted during the boot process, and the other partitions will be mounted after the completion of the mount behavior. Because of this, the directory associated with the boot process in the root directory cannot be placed in a different partition from the root directory. Which directories cannot be separated from the root directory? There are these below:
/ETC: Configuration file
/bin: Important Executive Gear
/dev: Required Appliance files
/lib: Function libraries required for the execution of files and modules required by the core
/sbin: Important System Execution files
These five directories must not be separated from the root directory in different partitions. Please recite it.