Linux root directory - detailed introduction

Table of contents

Introduction to Linux root path

Catalog introduction

/bin directory

/boot directory

/dev folder

/etc directory

/home directory

/lib and /lib64 directories

/media directory

/mnt directory

/opt directory

/proc directory

/root directory

/run directory

/sbin directory

/src directory

/sys directory

/temp directory

/usr directory

/var directory

Summarize


 

Introduction to Linux root path

This is the root directory.

The root is expressed as [/] in the path of Linux, a slash.

In the case of default login, it is the [/root] path, and we use the [cd ..] command to return to the root directory.

Use the [ls] command to view the content name of the root directory. Use [ll] to view the details of all files.

The content seen on the right side of the figure below is all the folders under the root directory. 

Catalog introduction

/bin directory

In the Linux system, the /bin directory is a directory for storing basic user commands (binary executable files) of the system. It contains some of the most commonly used commands, which can be executed directly by all users without specifying a path.

The functions of the /bin directory include:

  1. Store common commands: the /bin directory stores some of the most basic and commonly used commands, such as ls (list directory contents), cp (copy files), mv (move files), rm (delete files), mkdir (create directories) , cat (view file content), etc. These commands are loaded at system startup for use by users and scripts.

  2. System environment variable: The commands in the /bin directory are usually included in the system environment variable $PATH, which means that no matter where the current working directory is, users can directly execute these commands without specifying a complete path.

  3. Single-user mode: When the system starts in single-user mode (rescue mode), the basic commands in the /bin directory are the only available command sets. These commands can be used for system maintenance, repair, and troubleshooting.

It should be noted that the commands in the /bin directory are usually core components that come with the system, rather than software installed by users themselves. If the user has installed other software, its executable files are usually placed in the /usr/bin, /usr/local/bin or /opt directory.

To sum up, the /bin directory is the directory that stores the basic user commands of the system. These commands are available to all users and can be executed directly in the terminal without specifying the full path.

/boot directory

The boot directory in Linux is a directory used to store startup-related files. These files include the operating system kernel, bootloader, configuration files, and more. When the computer starts, the BIOS will first read the boot sector on the hard disk, and then hand over control to the boot loader, which then reads the files in the boot directory to start the operating system. Therefore, the boot directory is very important in the Linux system, which directly affects the startup and operation of the system.

/dev folder

The dev folder is a device folder, such as hard disk, U disk, keyboard, mouse and other device files.

The /dev directory is a special directory in the Linux system that contains all device files. In Linux, everything is considered a file, including hardware devices. Therefore, the files in the /dev directory are actually files associated with hardware devices, and they allow users and applications to interact with hardware devices.

The files in the /dev directory can be divided into two categories: character devices and block devices. Character devices refer to devices that can only process one character at a time, such as keyboards, mice, serial ports, etc. A block device refers to a device that can process a piece of data, such as a hard disk or a USB flash drive.

The role of the /dev directory is to provide a unified way to access hardware devices, so that users and applications can access hardware devices like ordinary files. In this way, users and applications can interact with the hardware device by reading and writing files in the /dev directory without knowing the underlying details of the hardware device.

/etc directory

This directory is a system configuration file. For example, when we modify the computer network card information, we will use the file content in this directory.

For example: Linux modify network card information - nanny-style operation process_Red Eye Aroma Blog-CSDN Blog This document.

This image is everything below ETC

/home directory

This directory means home.

 

This folder contains the home directories of all users. I only have an admin user here, so only one is displayed. After opening, you can also see the content of the corresponding user. Each user will have a directory dedicated to himself.

/lib and /lib64 directories

In the Linux system, the /lib directory is mainly used to store the shared library files required by the system. A shared library is a collection of executable code and data shared by multiple programs, and they contain the implementation of some operating system core functions.

The /lib directory usually contains the following types of shared library files:

  1. Dynamic Linking Libraries (Dynamic Linking Libraries): These library files are dynamically loaded into memory when the program is executed to provide the functions and services required by the program. Some common dynamic link library files include libc.so (C standard library), libm.so (math library), etc.

  2. Kernel Modules: These library files are used to extend and customize the functions of the Linux kernel. Kernel modules can be loaded into the kernel at runtime and provide additional driver or feature support. These library files are usually suffixed with .ko, such as drm.ko, usbcore.ko, etc.

  3. Hardware Firmware: Some hardware devices require specific firmware files to work properly, and these firmware files are usually stored in the /lib/firmware directory. For example, devices such as wireless cards, sound cards, etc. may require firmware files to load drivers.

In addition, the /lib directory may contain other important files and directories required by the system to support the normal operation of the system. In short, the /lib directory plays an important role in storing shared library files and files required by other systems in the Linux system.

/media directory

In Linux, the media directory is usually used to mount removable storage devices (such as U disk, CD/DVD disc, SD card, etc.). After connecting the removable device to the computer, enter the command in the terminal to mount the device, and the data stored in the device can be read and written in the Linux system. Usually, the device is mounted to the /media directory, such as /media/usb, /media/cdrom, etc. After finishing using, you need to execute the uninstall command umount to uninstall the device from the system, and then disconnect the device from the computer.

/mnt directory

In the Linux system, the /mnt directory is a directory used to temporarily mount the file system. It is a generic mount point used to mount other devices or filesystems into the system's directory tree.

The main functions of the /mnt directory include:

  1. Mount removable media: When you insert a removable media such as a USB flash drive, external hard drive, CD/DVD, etc., it is usually mounted to the /mnt directory in order to access the files in it.

  2. Mount other partitions: If you have other hard disk partitions or network shared partitions, you can mount them to the /mnt directory to make them available in the system.

  3. Temporary mount: Sometimes you need to temporarily mount some file systems, such as repairing system problems, backing up data, etc. At this time, you can choose the /mnt directory as the mount point.

It should be noted that the /mnt directory is usually only used for temporary mounting, and it is not recommended to place permanently mounted file systems in this directory. For file systems that need to be mounted for a long time, it is recommended to use other directories, such as /mnt/data, /mnt/storage, etc.

In summary, the /mnt directory provides a standard temporary mount point in the Linux system, which is convenient for users to mount external devices or other file systems to the system for access.

/opt directory

The /opt directory is the directory used to store third-party software in the Linux system. These third-party software are not provided by the system, but developed and provided by third-party companies or individuals. When installing third-party software, the software is usually installed in the /opt directory for unified management.

/proc directory

The proc directory is a virtual file system in the Linux kernel, which stores the running information of the current system. The files and directories in the proc directory are virtual, and their contents are dynamically generated rather than statically stored. By reading the files and directories in the proc directory, you can learn various information about the current system, such as running processes, status of corresponding processes, system hardware configuration, network status, etc.

/root directory

The /root directory is the home directory of the super user (root) in the Linux system. The super user is the user with the highest authority in the system, and the /root directory is the default working directory of the super user. In this directory, superusers can perform system management tasks, save important configuration files and scripts, etc. The /root directory is usually only accessible to super users, and other ordinary users cannot directly access this directory. This can ensure that the superuser's files and operations will not be changed or tampered with by other users, thereby improving system security.

/run directory

In the Linux system, the /run directory is a temporary file system (tmpfs) used to store runtime data generated when the system starts. The files and directories under this directory are created every time the system starts and are cleaned up when the system shuts down.

The /run directory is mainly used to store the following types of data:

  1. PID file: Some processes generate a file containing their process ID (PID) when they run, and these files are usually stored in the /run directory.
  2. Lock files: The process may need to use lock files to ensure the exclusivity or sequence of resources during runtime. These lock files are also stored in the /run directory.
  3. Socket file: Socket file can be used for communication between processes. These Socket files are usually stored in the /run directory.

The use of the /run directory is to regenerate these runtime data after the system is restarted, and it can also reduce disk access and improve system performance.

/sbin directory

The /sbin directory is a special directory in the Linux system, which stores system commands and executable files used by the system administrator (root user) for system management and maintenance. The commands in this directory are typically used for system initialization, startup, repair, and administrative tasks.

The commands and executable files in the /sbin directory mainly include:

  1. System management commands: such as shutdown (shutdown command), reboot (restart command), init (system initialization command), etc.
  2. System maintenance commands: such as fsck (file system check command), mount (mount command), mkfs (file system creation command), etc.
  3. Network management commands: such as ifconfig (network interface configuration command), route (routing table configuration command), iptables (firewall configuration command), etc.
  4. System log management commands: such as syslogd (system log daemon process), logrotate (log file rotation command), etc.

The commands in the /sbin directory are generally only authorized to be executed by the system administrator (root user), and ordinary users cannot directly execute these commands. This ensures the security and reliability of system administration commands.

/src directory

In Linux systems, the /src directory is usually the directory used to store source code files. It is an agreed directory to hold the source code of packages installed in the system.

The role of the /src directory is as follows:

  1. Source Code Storage: The /src directory is a common location for the source code for packages that developers download or compile. This makes it easy to view, modify and build packages.
  2. Package compilation: Many times, system administrators need to compile and install software packages from source code. The /src directory provides a default location so that the source code and compilation process of the software package can be managed in a unified manner.
  3. Software development: For developers, the /src directory is a habitual choice for storing source code files or projects written by themselves.

It should be noted that the /src directory is not a mandatory requirement of the Linux system, it is just a customary practice. In fact, the source code can be placed in any other location, as long as the correct path is specified when compiling or installing the package.

/sys directory

In the Linux system, the /sys directory is a virtual file system that provides detailed information and control interfaces for the kernel and hardware devices. It is a mechanism for accessing and managing kernel devices, drivers, and system information.

The main functions of the /sys directory are as follows:

  1. System Information: The /sys directory provides information about system hardware, kernel parameters, and configuration. For example, you can obtain CPU information, memory information, Device Tree, etc. through the /sys directory.
  2. Device management: The /sys directory provides an interface for accessing and configuring hardware devices. Each physical device and device driver has corresponding directories and files in the /sys directory, and device parameters can be read and set through these files.
  3. Kernel parameters: The /sys directory provides an interface for accessing and configuring kernel parameters. Through the files in the /sys directory, some kernel parameters can be modified, such as adjusting memory management and network settings.
  4. Device driver: The /sys directory provides information and control interfaces related to device drivers. You can interact with the device driver through the files in the /sys directory, such as loading, unloading, and restarting the device driver.

It should be noted that the content in the /sys directory is dynamically generated, which reflects the current state and configuration of the system. Therefore, the files and directories under the /sys directory may change as the operating status of the system changes.

/temp directory

In Linux systems, the /temp directory is a common directory for temporary file storage. It is used to store temporary files, temporary directories, and other temporary data. These files and directories will be automatically cleaned up after the system restarts, so there is no need for long-term storage.

The role of the /temp directory is as follows:

  1. Temporary file storage: The /temp directory is the default location for programs or systems to store temporary files during operation. These temporary files may be intermediate results generated when the program is running, temporary cache files, or other temporary data.
  2. Temporary directory creation: Some applications need to create a temporary directory at runtime to store temporarily generated files or data. The /temp directory provides a common location for these programs to create and use temporary directories.
  3. Temporary files for scripts and tasks: During script execution or task running, some temporary files may be generated to save intermediate results or auxiliary data. The /temp directory provides a convenient location to store these files.

It should be noted that the files and directories in the /temp directory will be cleared after the system restarts, so it is not suitable for long-term storage of important data. If you need to save long-term data, please use other suitable directories or storage methods. At the same time, in order to avoid security risks, it is recommended that only authorized users can access the /temp directory.

/usr directory

In the Linux system, the /usr directory is an important system directory, which contains user-installed applications, library files, documents, configuration files, and so on. Normally, the /usr directory is read-only, and only system administrators have permission to modify its contents. In the Linux system, the /usr directory plays a very important role. It allows users to easily install and manage various applications, and at the same time ensures the stability and security of the system.

/var directory

The /var directory is an important directory in the Linux system. It is mainly used to store various data files generated when the system is running, including log files, cache files, lock files, and so on. Specifically, the /var directory includes the following subdirectories:

  1. /var/log: Store system log files, including system startup logs, application logs, security logs, and more.

  2. /var/cache: Store cache files of various applications, such as the package cache of the package manager, the domain name resolution cache of the DNS server, and so on.

  3. /var/run: Store various temporary files generated when the system is running, such as process ID files, lock files, and so on.

  4. /var/spool: Stores various queue files, such as mail queues, print queues, and so on.

In short, the /var directory is a very important directory in the Linux system. It stores many important data files generated when the system is running, and plays a vital role in the normal operation of the system.

Summarize

The Linux root directory layout is a standardized file system layout, which defines the purpose and function of each directory, so that different Linux systems can maintain consistency and interoperability. The meaning of the root directory layout is as follows:

  1. Uniformity and standardization: The root directory layout defines a unified file system structure, enabling different Linux distributions to follow the same standard. In this way, users and developers can more easily work on different Linux systems, reducing the difficulty of learning and adapting to new systems.

  2. Maintainability: The root directory layout organizes files and directories according to their purpose and function, making it easier for system administrators and developers to manage and maintain the system. For example, log files are stored in the /var/log directory, configuration files are stored in the /etc directory, and executable files are stored in the /bin and /usr/bin directories.

  3. Security: The root directory layout limits the access rights of different users to each directory, thus improving the security of the system. For example, users can only have write permissions in certain directories, while other system-critical directories can only be written by administrators.

  4. Extensibility: The root directory layout allows users and developers to expand and customize as needed. For example, the /usr/local directory provides a space for users to install software themselves.

All in all, the significance of the root directory layout is to provide a unified, standardized and maintainable file system structure, which makes the Linux system easier to use, manage and develop, and brings better interoperability and security.

Guess you like

Origin blog.csdn.net/feng8403000/article/details/131604677