Home  >  Article  >  System Tutorial  >  Detailed explanation of Linux file system directory structure: root file system and the meaning of common folders

Detailed explanation of Linux file system directory structure: root file system and the meaning of common folders

王林
王林Original
2024-07-11 20:32:44704browse

Linux 文件系统目录结构详解:根文件系统与常见文件夹意义

From LinuxWiki

Tips: This article has not been updated for more than 11 years (4219 days). If you find that the content is outdated or incorrect, please feel free to improve it :)

Unlike Windows, which treats the hard disk as several independent partitions such as "C drive" and "D drive", Linux regards the entire file system as a tree, and the bark of this tree is called the root file system Linux port mapping. Indicated by /. Each partition is accessed as a folder through "Mount".

There are many folders in /. This article introduces the meaning of common folders. The directory structure of Linux is indeed relatively complex, but the settings are reasonable and the levels are clear. This article takes FHS2.3 as an example to introduce.

Tips:

If you like diagrams, you can refer to the Linux file layout and related discussions reprinted by LinuxToy.

Table of Contents

Root File System

/bin

This directory stores commands for all users to complete basic maintenance tasks. Bin is the abbreviation of binary, which represents a two's complement file, usually an executable file. Some commonly used system commands, such as cp, ls, etc., are stored in this directory.

/boot

Stored here are some core files used when starting Linux. Such as operating system kernel, boot program Grub, etc.

/dev

Contains all system device files in this directory. From this directory you can access various system devices. Such as CD-ROM, C disk drive, modulation mixer and video memory, etc. This directory also contains various useful functions, such as MAKEDEV for creating device files.

/etc

目录linux_目录怎么自动生成_linux mnt目录

This directory contains configuration files for the system and application software.

/etc/passwd

This directory contains user description information in the system, and each line records the information of one user.

/home

Storage personal files of ordinary users. Each user's home directory is named after their username under /home.

/lib

This directory stores the system’s most basic shared link libraries and kernel modules. Shared link libraries are functionally similar to .dll files in Windows.

/lib64

64-bit systems have this folder, a library for 64-bit programs.

/lost+found

This is not part of the Linux directory structure, but the place where the ext3 file system saves lost files. Improper crash operations and c drive errors can cause file loss, which means that these are marked as "in use" but are not listed on the data structure on the c drive. Under normal circumstances, the boot process will run the fsck program, which can detect such files. In addition to this directory on the "/" partition, there is a lost+found directory on each partition.

/media

The mount point of the connected device can be connected to qq for linux. The current operating system will generally manually mount devices such as USB flash drives to this folder.

/mnt

A temporary place to mount the file system. Normally this directory is empty linux mnt directory, and when we are about to mount the partition, we build a directory in this directory, and then mount the device we are about to access on this directory so that we can access the files . (Note that in GNOME, only folders mounted to /media will be displayed in "Computer", and folders mounted to /mnt will not be displayed as special devices. For details, see Manually Mount Partitions)

目录怎么自动生成_linux mnt目录_目录linux

/opt

Most third-party software is installed to this location by default, such as AdobeReader, google-earth, etc. Not every system will create this directory.

/proc

It is a virtual file system that exists in video memory. The status information of the kernel and process is saved above. Most are text files and can be viewed directly. For example, /proc/cpuinfo saves information about the CPU.

/root

This is the root user’s home directory. Much like the directories under /home reserved for individual users, this directory also contains entries relevant only to the root user.

/sbin

Executable files for super users, mostly system management commands, such as fsck, reboot, shutdown, ifconfig, etc.

/tmp

This directory is used to save temporary files. This directory has special permissions for Sticky, and all users can create and edit files in this directory. But only the file owner can delete the file. In order to increase the access rate of temporary files, some implementations place /tmp in video memory.

/usr

Static user-level applications, etc., see below.

/var

Dynamic program data, etc., see below.

/usr directory structure

/usr is generally a huge folder. The directory structure under it is similar to the root directory, but the files in the root directory are mostly system-level files, while /usr is user-level files, which are usually irrelevant to the specific system. .

Tips:

usr was originally the abbreviation of user, and /usr has the same role as today’s /home. At present, it is generally considered to be the abbreviation of UserSystemResourceslinux mnt directory, which usually contains user-level software, etc., compared with the root directory where system-level files are stored.

It should be noted that the program configuration files, dynamic data files, etc. will not be stored in /usr, so there is usually no need to change the contents of /usr except for installing and uninstalling the software. It is said that when the system is running normally, /usr can even be mounted read-only. Because of this characteristic, /usr is often defined in a separate partition, and sometimes multiple computers can even share a /usr.

/usr/bin

Where most daily applications are stored. If /usr is placed in a separate partition, Linux single-user mode cannot access /usr/bin, so programs critical to the system should not be placed in this folder.

/usr/include

Directory where C/C++ header files are stored

/usr/lib

System library files

/usr/local

This folder is empty in the newly installed system and can be used to store personally installed software. The directory structure in /usr/local where local software is installed is similar to /usr

/usr/sbin

System management programs not used in single-user mode, such as apache2, etc.

目录怎么自动生成_目录linux_linux mnt目录

/usr/share

Architecture-independent data. Most software is installed here.

/usr/X11R6

This directory is used to save all files required to run X-Window. This directory also contains configuration files and two's complement files used to run the GUI.

/usr/src

Source code

/var directory structure

/var includes some data files, such as system logs, etc. The storage of /var makes it possible for /usr to be mounted read-only.

/var/cache

Cache files for applications

/var/lib

App information and data. Data such as databases are stored in this folder.

/var/local

Program information and data in/usr/local

/var/lock

目录怎么自动生成_linux mnt目录_目录linux

Lock files

/var/log

Log files

/var/opt

/opt program information and data

/var/run

The information of the executing program, such as PID file should be stored here

/var/spool

Storage program’s spool data (i.e. spooldata)

/var/tmp

Temporary files

References

The above article also draws on this kind of information in terms of language.

FHS website TLDP:LinuxFilesystemHierarchy

Taken from "%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"

1 Category:Linux Basics

The above is the detailed content of Detailed explanation of Linux file system directory structure: root file system and the meaning of common folders. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn