English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux System Directory Structure

After logging into the system, enter the command in the current command window:

 ls /

You will see as shown in the following figure:

Hierarchical directory structure:

The following is an explanation of these directories:

  • /bin:
    bin is an abbreviation for Binaries (binary files), and this directory contains the most frequently used commands.

  • /boot:
    This directory contains some core files used when starting Linux, including some link files and image files.

  • /dev :
    dev is an abbreviation for Device, and the directory contains the external devices of Linux. In Linux, the way to access devices is the same as accessing files.

  • /etc:
    etc is an abbreviation for Etcetera, and this directory is used to store all the configuration files and subdirectories required for system management.

  • /home:
    The user's home directory. In Linux, each user has their own directory, usually named after the user's account, such as alice, bob, and eve in the figure above.

  • /lib:
    lib is an abbreviation for Library, and this directory contains the most basic dynamic link shared libraries of the system, which are similar to the DLL files in Windows. Almost all applications need to use these shared libraries.

  • /lost+found:
    This directory is usually empty. After an illegal shutdown of the system, some files are stored here.

  • /media:
    The Linux system can automatically recognize some devices, such as USB flash drives, CD-ROMs, etc. After recognition, Linux will mount the recognized devices to this directory.

  • /mnt:
    The system provides this directory for users to temporarily mount other file systems. We can mount the CD-ROM on /mnt/ Then enter the directory to view the contents of the optical drive.

  • /opt:
    opt is an abbreviation for optional, which is the directory for additional software installation on the host. For example, if you install an ORACLE database, you can place it in this directory. It is empty by default.

  • /proc:
    proc is an abbreviation for Processes (processes)./proc is an alias for Processes (processes), which is a pseudo-file system (i.e., a virtual file system) that stores a series of special files representing the current kernel running state. This directory is a virtual directory, which is a mapping of the system memory. We can obtain system information by directly accessing this directory.
    The content of this directory is not on the hard disk but in memory. We can also directly modify some files in it, for example, we can use the following command to block the host's ping command so that others cannot ping your machine:

    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
  • /root:
    This directory is for system administrators, also known as super users, and is the home directory of users with superuser privileges.

  • /sbin:
    s means Super User, which is the abbreviation of Superuser Binaries (binary files for superusers), and this directory stores system management programs used by system administrators.

  • /selinux:
     directory is Redhat/directory unique to CentOS, Selinux is a security mechanism, similar to the firewall in windows, but this mechanism is more complex, and this directory stores files related to selinux.

  • /srv:
     This directory stores some data that needs to be extracted after some services are started.

  • /sys:

    Linux2.6 A significant change in the kernel. The directory below installs 2.6 a new file system sysfs has emerged in the kernel.

    sysfs file system integrates the following3information of various file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo terminals.

    This file system is a direct reflection of the kernel device tree.

    when a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem.

  • /tmp:
    tmp is the abbreviation of temporary, this directory is used to store some temporary files.

  • /usr:
     usr is the abbreviation of unix shared resources, this is a very important directory, many application programs and files of users are placed in this directory, similar to the program files directory under windows.

  • /usr/bin:
    application programs used by system users.

  • /usr/sbin:
    Superuser uses more advanced management programs and system daemons.

  • /usr/src:
    The default directory for placing kernel source code.

  • /var:
    var is the abbreviation of variable, this directory stores things that are constantly expanding, and we are accustomed to placing those frequently modified directories under this directory. Including various log files.

  • /run:
    is a temporary file system that stores information since the system started. When the system restarts, the files in this directory should be deleted or cleared. If your system has /var/The run directory should point to run.

In the Linux system, there are several important directories that need to be paid attention to, do not delete or change internal files at will.

/etc: As mentioned above, this is a system configuration file, changing any file in this directory may cause the system to fail to start.

/bin, /sbin, /usr/bin, /usr/sbin: This is the directory where the system's predefined executable files are placed, for example, ls is located in /bin/the contents of the ls directory.

it is worth mentioning that,/bin, /usr/bin is a set of commands for system users (common users except root), and/sbin, /usr/sbin is a set of commands for root use.

/varThis is a very important directory, many programs run on the system, and each program will generate corresponding logs, which are recorded in this directory, specifically in /var/The log directory, as well as the default placement of mail, is also here.

System startup instructions

  • /boot:Stores the kernel files used to start Linux, including link files and image files.

  • /etc:StoredAllThe system needsconfiguration filesandSubdirectory list,Changing the files in the directory may cause the system to fail to start.

  • /libThis is where the basic code library (such as c++Library), which is similar to the DLL files in Windows. Almost all applications need to use these shared libraries.

  • /sysThis is Linux2.6A significant change in the kernel. The directory below installs2.6A new file system in the kernel sysfs. The sysfs file system integrates the following3Types of file system information: proc file system for process information, devfs file system for devices, and devpts file system for pseudo terminals. This file system is a direct reflection of the kernel device tree. When a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem

Command set:

  • /bin:Contains the most commonly used programs and commands

  • /sbin:Programs and commands that can only be used by system administrators.

External file management:

  • /dev :Device (device) abbreviation, stores Linux's external devices.Note:In Linux, the way to access devices and files is the same.

  • /mediaThis is similar to Windows'other devices,For example, USB flash drives, optical drives, etc., after identification, Linux will place the device in this directory.

  • /mntIt is used for temporarily mounting other file systems, and we can mount the optical drive here./mnt/Then enter the directory to view the contents of the optical drive.

Temporary files:

  • /runIt is a temporary file system that stores information since the system boot. When the system restarts, the files in this directory should be deleted or cleared. If your system has /var/The run directory should point to run.

  • /lost+foundIt is usually empty. After an illegal shutdown of the system, some files are stored here.

  • /tmpThis directory is used to store some temporary files.

Account:

  • /rootThis is the user home directory of the system administrator.

  • /homeThis is the user's home directory, named after the user's account.

  • /usrThis directory contains many applications and files for users, similar to the program files directory under Windows.

  • /usr/bin:Applications and commands used by system users.

  • /usr/sbin:Superuser uses more advanced management programs and system daemons.

  • /usr/src:The default directory for placing kernel source code.

to be used during the operation process:

  • /var: Stores frequently modified data, such as program execution log files (/var/under the log directory).

  • /proc: ManagementMemory space!A virtual directory, which is a mapping of system memory, we can directly access this directory to, obtain system information. The content of this directory is not on the hard disk but in memory, and we can also directly modify some files in it to make modifications.

For expansion:

  • /opt: It is empty by default, we can install additional software in this directory.

  • /srv: Stores data that needs to be extracted after the service starts(Empty if no server is used)

Directory

In the Linux or Unix operating system, all files and directories are organized into an inverted tree structure starting with a root node.

The top level of the file system is the root directory, the system uses / to represent the root directory. Under the root directory, it can be both directories and files, and each directory can contain subdirectories and files. Repeatedly, a vast file system can be formed.

There are two special directories in the Linux file system: one is the working directory of the user, also known as the current directory, which can be represented by a point .; the other is the parent directory of the current directory, also known as the parent directory, which can be represented by two dots ..

    .: Represents the current directory, also can use ./ to represent;

    ..: Represents the parent directory, also can be ../ to represent.

If a directory or filename starts with a dot '.', it indicates that the directory or file is a hidden directory or file (such as: .bashrc). That is, it does not display the directory or file by default when searching in the default way.