


Detailed explanation of Linux file system directory structure: root file system and the meaning of common folders
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
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)
/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.
/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
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

The main tasks of Linux system administrators include system monitoring and performance tuning, user management, software package management, security management and backup, troubleshooting and resolution, performance optimization and best practices. 1. Use top, htop and other tools to monitor system performance and tune it. 2. Manage user accounts and permissions through useradd commands and other commands. 3. Use apt and yum to manage software packages to ensure system updates and security. 4. Configure a firewall, monitor logs, and perform data backup to ensure system security. 5. Troubleshoot and resolve through log analysis and tool use. 6. Optimize kernel parameters and application configuration, and follow best practices to improve system performance and stability.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.
