<Laruence's private dish> -- Reading Notes -- HFS

Source: Internet
Author: User

How to organize a Linux File System-FHS

When we use Linux, whether it is RedHat or SUSE, we will find that the directory structure under them is always slightly different. This is because most mainstream releases follow FHS (filesystem Hierarchy Standard ).

FHS specifies the directories/,/usr, And/var which specify the main sub-directories, files placed in each sub-directory, and their usage.

/Directory Introduction
The following sub-directories are mounted under a root directory:

1. Regular directory:

Directory Name Description
/Bin Stores binary commands that can be used by users, such as LS and VI.
/Sbin S refers to system, which is used to store system management commands that only root can execute, including system boot and repair commands.
/Lib or/lib64 Place the driver and library files. The library files required for command execution in/bin and/sbin are all placed in this directory.
/Etc
Place the System Configuration File
/Srv This directory is used to store data of certain services, such as WWW and FTP.
/Tmp Used to place temporary files
2. Special directory:
Directory Name Description
/Boot The static files required for system boot are stored in this directory, such as kernel and bootload.
/Dev There are two types of device files used to store device files: physical devices that are indeed connected to the host, and virtual devices that are virtualized by the operating system. Image/dev/tty0 is a virtual console
/Home In general, each common user has a subdirectory with the same name under this Directory, which serves as the Home Directory of the user.
/Root
Root's home directory
/Media Mount Points of removable media, such as USB flash drives and DVDs.
/Mnt Temporary mount point of the file system, such as NFS
/OPT Third-party software storage and installation directory (not commonly used)
/Lost + found When a file system error occurs, the lost parts will be put in this directory. When the file system is repaired, fsck will search in this directory. Each new file system has this directory. (Not commonly used)
3. pseudo File System

Directory Name Description
/Proc
It exists in the memory and does not occupy the actual physical space. The following special files can be used to extract or send information to the kernel.
/Sys A new virtual file system added after the 2.6 kernel is designed to better support Hot Plug-in devices. The content is similar to/proc, but the hierarchical view of the device information of the Hot Plug-In device can be displayed.
There are two very special directories:/Var and/usr. These two directories are also required for the system to start in multi-user mode. So we will introduce it separately below

/Usr directory Introduction

/Usr according to laruence, this directory name is short for uw.software resource. FHS recommends that most standard programs be stored in the corresponding subdirectories under the/usr directory.

The/usr directory contains the following sub-directories:

Directory Name Description
/Usr/bin Most of the executable commands and executable files are stored in this directory.
/Usr/sbin The less critical system management commands are generally placed here. The most common is the management commands of some network services.
/Usr/lib or/usr/lib64 This file is used to place object files and shared libraries. By default, this file cannot be directly used by users or shells. To put it bluntly, it is designed for applications.
/Usr/etc This directory is usually empty because RedHat configuration files are all placed under/etc.
/Usr/share Used to place documents that can be used in various architectures, such as man manuals and various descriptions of software.
/Usr/libexec
Used to place small assistant programs that can be called by other programs
/Usr/include Header file used to place C
/Usr/src Used to place the original code
/Usr/local The sub-directory under this directory is basically the same as the/usr Directory, which is used to install software locally for the administrator. Sometimes you can install the new software in this directory to upgrade security.

/Var directory Introduction

/Var is short for variable. Literally, it is variable. In fact, it is true. Generally, after a new system is installed, the/usr directory is usually the largest, but with the use of the system, the/var directory will become larger and larger.

What is the/var directory used? In FHS, the/usr directory can be used as a shared directory through NFS for other hosts. There are so many important files in the/usr directory. When it is shared out, it is generally recommended to mount it in read-only mode. To run the program, it must generate data, such as log information and process number information. Which of the following information is stored in the/var directory.

The/var directory contains the following sub-directories:

Directory Name Description
/Var/log
Log File storage directory
/Var/run
After the program runs, the PID is usually placed in this directory.
/Var/lock
When some resources or files in the system can only be used by one program at a time, the resource or file will be locked, and the locked file will be placed under this directory.
/Var/lib
The data files to be used during the program running are stored in this directory. For example, all the data required for rpm query is stored in the/var/lib/RPM directory.
/Var/spool
It is usually used to place data waiting in queue for other programs to use. After other programs are used, they are usually deleted. For example, the/var/spool/mail directory is used to set the new message received by the system. When the user receives the message, it will be deleted in principle.

We recommend that you use the following code to partition a file:

  1. In the operating system, the variable is separated from the variable. That is to say, with the use of the operating system, the occupied space of the directory will continue to grow. It is best to divide the Directory into a separate partition and mount it, rather than partition it. Otherwise, when the/directory is too large, it will cause system instability, and it is not easy to find the specific directory that fills up the/partition.

  2. It is best to separate the operating system from the application. A. the disk where the operating system is located will not be read/written frequently and will not be damaged easily. B. If the operating system is damaged, application data will not be affected. It can be easily repaired when the operating system is backed up. C. when the application partition fails, the system cannot start normally. Because the application is used as a separate partition, it can be disabled first. After the operating system starts normally, use tools such as fsck to fix application partitions.

Directory tree

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/49/F7/wKiom1QgOW7x2j-OAADq90i22Qc080.jpg "Title =" dir_tree.png "alt =" wKiom1QgOW7x2j-OAADq90i22Qc080.jpg "/>

Absolute path, relative path

Absolute path: All paths starting with "/" are called absolute paths. They are mostly used for script execution.

Relative Path: The relative path refers to the current location. There are two commonly used symbols:. (current directory).. (the upper-level directory of the current directory.

This article is from the "Monthly White" blog, please be sure to keep this source http://yuebaibai222.blog.51cto.com/2535988/1557124

<Laruence's private dish> -- Reading Notes -- HFS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.