Linux operating system directory configuration standard FHS details

  

Because there are so many Linux developers, if everyone uses their own directory configuration method, it will bring a lot of management problems. Can you imagine that after you enter a business, is the Linux directory configuration method you are exposed to completely different from what you have learned before? hard to imagine. Therefore, there was a so-called Filesystem Hierarchy Standard (FHS).

FHS is actually just a specification of what files should be placed in each of the main directories under the root directory (/). The FHS defines two layers of specifications. The first layer is, /What files should be placed in each of the following directories, such as /etc should place the settings file, /bin and /sbin should be placed executable files and so on. The second layer is defined for subdirectories of the /usr and /var directories. For example, /var/log places system login files, /usr/share places shared data, and more.

Since FHS only defines the file data that should be placed in the directory contents of the top (/) and sub-layers (/usr, /var), it can be developed in other sub-directory levels. The staff has configured it themselves. For example, FC4's network setup data is placed in the /etc/sysconfig/network-script/directory, but SuSE Server 9 places the network in the /etc/sysconfig/network/directory with different directory names.

Also, in Linux, all files and directories start with the root directory /. That is the source of all directories and files. Then branch one by one, a bit like a tree. Therefore, we also call this directory configuration method: "directory tree" The main features of this directory tree are:

The starting point of the directory tree is the root directory (/, root).

Each directory can use not only the local-partitioned file system, but also the file system on the network. For example, you can use a Network File System (NFS) server to load a specific directory, and so on.

The file name (including the full path) of each file in this directory tree is unique.

In addition, depending on the way the file name is written, the path can also be defined as an absolute path and a relative path (relative). The absolute path is the file name or directory name written by the root directory (/), such as /home/dmtsai/.bashrc; the relative path is the file name relative to the current path. For example, ./home/dmtsai or ../../home/dmtsai/and so on. Anyway, at the beginning, it is not /is a way of writing relative paths. It must be understood that the relative path is represented by the relative position of the current path. For example, currently in the /home directory, how do you write if you want to enter the /var/log directory?

cd /var/log(absolute)

cd ../var/log(relative)

Because in /home, you have to go back to the previous level ( After ../), you can continue to move to /var.

Pay special attention to these two special directories:

.: indicates the current directory, you can also use ./to indicate.

..: indicates the upper level directory, which can also be represented by ../.

The directory concept with .. is very important. You will often see commands such as cd .. or ./command, which means the working state of the upper layer and the current directory. In addition, the character limit size for “filename” &"full file name (file name written by /)” is:

The maximum allowable file name for a single file or directory is 255 Characters. The full file name containing the full path name and directory (/) is 4096 characters.

We know that /var/log/has a file named message, and the maximum file name of this message file can be up to 255 characters. The two upper directories of var and log can be up to 255 characters long. But in general, the full file name such as /var/log/messages can be up to 4096 characters.

Tip: Root has a lot of meaning in Linux. From the perspective of “accounts”, root refers to “system administrator” status. If you look at the “directory”, root refers to the root directory, which is /. Pay special attention.

Copyright © Windows knowledge All Rights Reserved