In Windows, we see disk drive identifiers, such as C:\, E:\, followed by file and directory names. Linux is completely different from Windows. In Linux you can run ls in the root directory and observe its directory structure:

/– the root directory


As the name implies, the root directory is the directory where all directories are located. It is the root of all directories in Linux, and in a way, it is somewhat similar to the disk drive symbol in Windows. As you will see later, all other directories begin with a slash.

/bin– Directory for storing important user binaries


Bin is short for binary. The /bin directory holds very important user binaries, which are basically programs. Note that /bin stores commands that can be operated in single-user maintenance mode. These commands can be used by root and common users. In/bin we can see the Linux commands we use most often, such as chmod and du.

/boot– The directory for storing files required for system startup


/boot stores files required for system startup, such as EFI, GRUB, and the Linux kernel.

/dev– Device file directory


Linux treats everything as a file, including devices, whether physical hardware or virtual. Physical hardware, such as the first detected hard disk, is mounted to /dev/sda, the second hard disk is mounted to /dev/sdb, and so on. Virtual devices such as NULL, Random, STderr, STDIN, and STDout.

/etc– Configuration file directory


Etc, Et cetera, Et cetera, Et cetera, Et cetera, Et cetera, Et cetera, Et cetera, Et cetera, Et cetera Note that system configuration files are stored in /etc. Configuration files for specific users are stored in the/home directory of each user.

/home– User Directory


The /home directory stores the user directory of each user. For example, if a user is named Tom, /home/Tom is his user directory. The user directory stores user data and user configuration files, such as. Common users can access only their own user directories, but cannot access others’ directories. Root users do not have this restriction.

/lib– Important shared library directory


The /lib directory houses shared libraries for important binaries in /bin and /sbin. In addition, shared libraries required by binaries in /usr/bin are stored in /usr/lib.

/lost+found– Restore the file directory


Every Linux file system has a directory called/lost+found. When the file system crashes, a file system self-check will be performed on the next startup. Any files that were damaged during the crash will be put into/Lost +found, and you can try to find and recover them.

When you mount some removable media (such as CD, USB disk, cd-rom drive, etc.) to your computer, the system will automatically create a subdirectory under/media. Then you can access the media by accessing this subdirectory. For example, if you insert a CD on your computer, a subdirectory is automatically generated in the/media directory. You can access this subdirectory to access the contents of the CD.

/mnt– Temporary mount point directory


MNT is short for mount. After a device is mounted to the system, directories such as CD/DVD-ROM drives, file systems, and CDS are generated in the/MNT directory.

/opt– Optional package directory


Opt is Optional. Optional software packages installed in the system are stored in the/opt directory.

/proc– Kernel and process file directories


/proc is a virtual directory that does not contain any standard files. When the system starts, it checks the current kernel and hardware information and places it in this directory (which is actually in memory). You can use cat /proc/meminfo to see some information about memory, or cat /proc/version to see Linux kernel information.

/root– Home directory of user root


The root user’s home directory is located at /root.

/run– Application status directory


The /run directory is used to store ephemeral files, such as sockets and PID files, that are needed during the running of applications. These files are very important for the running of applications. Therefore, they cannot be placed in/TMP because files in/TMP may be deleted by the system.

/sbin– Directory for binary files used by system administrators


The /sbin directory is similar to the /bin directory in that it stores binary files. In particular, the /sbin directory stores system management commands, which can be used only by the root user.

/srv– Service data directory


The/SRV directory is mainly used to store the data of network services provided by the system. If you run an HTTP server on the machine to provide static files, the/SRV/HTTP directory will store these static files. If you run an FTP server to provide files, the/SRV/HTTP directory will store the static files. The/SRV/FTP directory will store these files.

/tmp– Temporary file directory


Some temporary files will be stored in the/TMP directory. Generally, after the system restarts, the files under/TMP will be automatically deleted. Some monitoring programs will also delete files.

/usr– User binary and read-only file directories


The /usr/bin directory is used to store programs used by users. It is obvious that Linux stores programs used by ordinary users separately from those used by the system. For example, as mentioned above, important programs used by the system are stored in /usr/bin, and less important programs are stored in /usr/bin. Less important hypervisors are stored in /usr/sbin instead of /sbin. Usr is also known as the UNIX Software Resource, which is an earlier term. Here are some common subdirectories in/usr:

  1. /usr/bin stores user commands
  2. /usr/include stores header and include files for the programming language
  3. /usr/lib holds library functions and object files for each application
  4. /usr/local Specifies the installation directory for the software downloaded by the system administrator
  5. /usr/sbin stores uncommon system commands
  6. /usr/src stores the source code

/var– Change the data directory


/var is used to store frequently changing data, such as log files and cache files. Here are some common subdirectories in/var:

  1. /var/cache stores temporary files generated when the application runs
  2. /var/lib stores the data files required by the program. Each software has its own directory in this directory
  3. /var/lock Stores the lock status of the program
  4. /var/log Stores various log files
  5. /var/mail stores personal email addresses
  6. /var/run Some programs will put their PID and socket files in this directory after running

Software Installation Specifications

According to FHS(www.pathname.com/fhs/) official documents refer to… Their main goal is to let users know where installed software is usually placed, so they want independent software developers, operating system makers, and users who want to maintain systems to follow FHS standards. In other words, the focus of the FHS is to regulate what kind of data should be placed in each particular directory. This has a lot of advantages, because Linux is able to develop the unique style that developers want from its existing look (directory architecture unchanged).

1. Shareable:

A directory that can be shared with other systems for mounting. Therefore, data including execution files and users’ emails can be shared with other hosts on the network for mounting.

2. Unshareable:

The device files running on their machines or socket files related to procedures, etc., are only related to their own machines, so of course it is not suitable to share with other hosts.

3. constant

Some data does not change very often, following distribution without change. For example, function libraries, file description files, host service configuration files managed by the system administrator, etc.

4. Changeable:

Frequently changing data, such as login files, newsgroups that can be accepted by the average user, etc.

In fact, FHS only defines what data should be placed at the bottom of the three levels of the directory tree:

  • /(root, root directory) : this parameter is related to starting the system

  • /usr (Unix software resource) : related to software installation/execution

  • /var (variable) : relates to the system operation process

Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station