Linux directory classification description

        The Linux root directory generally includes the following directories, and here are some summary of the characteristics of these directories. (centos8 as an example)

         1. /var directory

        The /var directory is a directory that contains frequently changing files. It is the abbreviation of Variable, and some people interpret it as Versioned Archives. Usually includes the following:

        Log files (log files): log files of various systems, applications and tasks, such as /var/log/messages, /var/log/syslog, etc.;

        Mail (mail): E-mail messages sent and received are stored in the /var/mail directory;

        Printer (printer): Print related temporary files and spool directories, stored in the /var/spool directory, including print queues, etc.;

        Databases (databases): database operation and storage files, such as MySQL, etc.;

        Packages (packages): including installed software and library files, stored in the /var/lib directory;

        Lock files (locks): lock files, pid files of running processes, etc., stored in the /var/lock directory;

        Running directory (run): Save the PID file of the running process in the /var/run directory.

        The /var directory has a unique directory structure and purpose, and plays an important role in the Linux system. In the process of maintaining the Linux system, the management and maintenance of the /var directory is very important to prevent unexpected system failures or data loss.

        2. /etc directory

        The /etc directory contains configuration files for the system. These files are files that need to be read when the system starts, and also contain configuration information required by many programs in the system, which can be regarded as the "system settings" page of the computer system. The files in this directory can usually be divided into the following categories:

        System configuration files: various hardware devices and configuration files required by the system, such as network configuration files (/etc/sysconfig/network), system startup files (/etc/rc.d/rc.local), etc.

        Software configuration files: configuration files required by various software, such as DNS configuration files (/etc/resolv.conf), SSH configuration files (/etc/ssh/sshd_config), etc.

        Security files: including password files and shadow files, which store all users and corresponding passwords and encrypted information, as well as some configuration files related to system security, such as sudo configuration files (/etc/sudoers), firewall configuration files (/etc/ sysconfig/iptables), etc.

        Script files: including various script files, such as startup script (/etc/init.d/), scheduled task script (/etc/crontab), etc.

        The /etc directory is a very important directory that contains files that are essential to every aspect of the operation of the computer system. At the same time, because they are system and application configuration files, they may appear equally important to the health of the system. Wrong configuration can lead to an unstable state of the system, while correct configuration can enhance the security, performance and functionality of the system. Therefore, for Linux system administrators, it is very important to back up, update and manage the files in the /etc directory in time.

        3. /dev directory

        The /dev directory is a virtual file system used to store device drivers. /dev is the abbreviation of Device.

        Each file in the /dev directory is an interface of the kernel virtual file system, and they represent hardware devices, disk partitions, terminal devices, etc. on the computer system.

        The device files stored in the /dev directory can usually be divided into the following three categories:

        Block Device: Represents random-access storage devices such as hard disks, optical drives, and U disks. Their names in the /dev directory usually start with "sd" (SCSI hard disk) or "hd" (IDE hard disk), such as /dev/sda1 means the first partition of the first SCSI hard disk.

        Character Device (Character Device): represents a serial port, a modem, an input and output device, etc. Their names in the /dev directory usually start with "tty" (teletype), such as /dev/ttyS0 means the first serial port device.

        Network Device: Represents a network card. Their names in the /dev directory are usually file names beginning with "eth" (Ethernet), such as /dev/eth0 means the first network card device.

        The device files in the /dev directory are a very important part of the Linux system because they provide an interface to access hardware devices. Any device-related operations are performed through these device files in Linux. Therefore, understanding the role and structure of the /dev directory is very important, especially for system administrators and developers.

        4. /boot directory

        Used to store files related to the Linux kernel and boot loader (Bootloader). These files are necessary for the computer to start and load the operating system. The /boot directory usually includes the following files and directories:

        vmlinuz: It is a compressed image of the kernel, the core of the Linux operating system. It contains all drivers and other core components needed by the operating system to start.

        initrd.img: It is an initial memory file system that contains files and drivers that may be required during system startup.

        grub directory: GRUB (GNU GRand Unified Bootloader) is the most commonly used boot loader, which allows users to select and boot multiple operating systems or kernel versions. The /boot/grub directory contains GRUB configuration files and the associated boot loader.

        memtest86+: It is a system memory testing tool that detects memory faults in computer hardware.

        The /boot directory is required for starting the Linux system. If the files or directories in the /boot directory are modified or deleted, the operating system may not start normally. Therefore, administrators should handle the /boot directory with great care, especially during system updates and upgrades.

        It should be noted that the /boot directory is usually only used to store boot and kernel files, and should not store other data files. This is because the /boot filesystem is usually small and is loaded when the computer starts up, which can affect the system boot load time if the /boot directory is filled with other files.

        5. /srv directory

        The /srv directory is a standardized directory for storing service data. Among them, srv is the abbreviation of "service".

        In a Linux system, service data usually includes website files, file sharing, FTP upload directories, and so on. The path of these service data is usually specified in the service configuration file, and the /srv directory provides a standardized directory structure, enabling administrators and developers to easily find and manage these service data.

        The /srv directory is usually empty and does not contain actual service data, but serves as the root directory of service data, where subdirectories for service data are created and managed. For example, /srv/http is a common website file root, and /srv/samba is a common Samba file share root.

        In the standardized Linux file system, the /srv directory is one of the specified standard directories, which is independent of the location of the operating system and software installation. This means that no matter which Linux system you use the service on, you should be able to find the corresponding service data in the /srv directory. In addition, the use of the /srv directory also contributes to the cleanliness and simplicity of the file system.

        In general, the /srv directory is a standardized directory structure for storing service data, which is widely used in Linux systems and helps to manage service data and file system cleanliness.

        6. /usr directory

        The /usr directory is used to store minor files, applications, library files, etc. of the system. Among them, usr is the abbreviation of Unix Software Resource (Unix software resource). It mainly includes the following subdirectories:

        /usr/bin: Used to store commands and applications used by ordinary users, such as ls, cp, etc.;

        /usr/sbin: Used to store commands and applications used by system administrators, such as fdisk, iptables, etc.;

        /usr/include: store header files for compiling programs;

        /usr/lib: stores library files related to the operating system, including dynamic link libraries (.so files), shared object files (.a files), etc.;

        /usr/local: used to store programs and files that have nothing to do with the operating system. These programs and files are compiled by the administrator himself or others, rather than installed through the standard package management system of the operating system;

        /usr/share: Contains shared files such as other programs, documents, icons, backgrounds, etc.;

        /usr/games: stores game programs.

        In general, the /usr directory does not have much impact on the normal operation of the system, but it is an important part of the Linux system, and it is also very important for administrators and programmers. The files in the /usr directory are often not installed by default during system installation or shared by many software, and these files must be used to run the software, so it is very necessary to manage the files and subdirectories in the /usr directory.

        7. /opt directory

        The /opt directory is generally used to install large, independent third-party software, such as Java Runtime Environment (JRE), .NET Core Framework, and so on.

        The top-level directories under the /opt directory are usually subdirectories that have nothing to do with the name of the package or its vendor and have no specific naming scheme. Usually these packages are distributed as compressed files or binaries, administrators can either unpack them or create a new directory within the /opt directory and copy all files and directories into it.

        The /opt directory is the Linux version of the "Program Files" directory, which helps to separate applications and data, making the system cleaner. It can also help manage multiple different versions of the same software package or software from different vendors, making administrators' jobs easier.

        In addition to large third-party software, the /opt directory can also be used to store software and data that are writable by other directories and not part of standard system management, such as virtual machine images, shared data, etc. However, if the /opt directory is used to store other files that are not part of the system management, it should be properly protected to prevent unauthorized reading and modification.

        In summary, the /opt directory is a reasonable directory for storing large independent software packages, which can help administrators better manage third-party applications, provide better system cleanliness, and keep different versions of software, as well as software and It is easier to store data separately.

        8. /sys directory

        The /sys directory is a virtual file system used to display and modify system hardware and driver information. This directory provides information about the kernel device tree (Device Tree) corresponding to the virtual files displayed in /sys, which is also maintained by the kernel. There are many files and directories included here, including the following important ones:

        /sys/devices: Contains information of all devices in the system, each device has a corresponding directory, which contains the device driver, device file name, and other information related to the device.

        /sys/bus: Contains information of all buses, each bus has a corresponding directory, which contains the bus driver, device file name and other information related to the bus.

        /sys/class: Contains information of all device classes, each device class has a corresponding directory, which contains the attributes of the device class and other information related to the device class.

        /sys/block: Contains information of all block devices (hard disks, U disks, etc.), each block device has a corresponding directory, which contains the block device driver, device file name and related to the block device additional information for .

        The /sys directory is a virtual file system that displays information about many hardware, devices, modules, and other kernel functions of the Linux kernel. It serves as part of Linux system configuration and administration and should not be directly modified by users or applications. Managing the /sys directory requires system administrators to have certain system knowledge and experience.

        9. /home and /root directories

        The place where the home directories of normal users are kept. In Linux, each common user has a corresponding home directory named after the user name, and the home directory is usually located under the "/home" directory, such as "/home/username".

        Each user has full read, write, and execute permissions in their home directory. Users can store personal files, configuration files, desktop files, and other important data in their home directory. These data are usually protected by user passwords, and only the user can read and modify them. Users can also create folders under the home directory in which to manage and organize their files. It is also the default starting working directory for users on the system.

        The /home directory is writable by default, but this directory is usually maintained and managed by system administrators. Administrators can perform space quota and authority management on the /home directory to ensure system stability and security.

        In a multi-user environment, the use of the /home directory is very important because it allows administrators, users, and software to isolate the data of different users, which can better maintain the security and reliability of the system.

        The "/root" directory is the home directory of the system administrator (that is, the root user), which is similar to the "/home" directory of ordinary users.

        Specifically, the "/root" directory is the home directory of the root user, and only the root user has access rights. Generally, the root user should not store important data in the /root directory, but should use other directories to avoid losses caused by data that may be leaked after the system is hacked.

        The /root directory usually includes some system-level configuration and data files, such as system configuration files, log files, password files, and so on. Administrators can use the /root directory to manage and maintain the system's software and configuration.

        It should be noted that "/" (root directory) and "/root" (root user's home directory) are different directories. In a Linux system, the /root directory contains all other directories and files, while the /root directory contains only the files and directories of the root user. Therefore, the /root directory can be regarded as a folder under the root directory.

        10. Other catalogs

        /media directory: This directory is used to automatically mount removable devices, such as U disk, CD/DVD, etc. When the device is plugged into the computer, the system automatically mounts it in a subdirectory under the /media directory.

        /mnt directory: This directory is used to manually mount the file system, such as mounting a disk partition when installing a new hard disk.

        /proc directory: This directory is a virtual file system that contains detailed information about running processes. The files and subdirectories under this directory provide various information such as process, memory, network, hardware, etc.

        /run directory: This directory is used in many Linux distributions to store runtime information, such as PID files (process numbers), socket files (sockets), and other temporary files. It is intended to replace the /var/run directory and is automatically mounted on boot.

        /tmp directory: This directory is used to store temporary files, such as installation programs or decompressed files. Normally, files under the /tmp directory are deleted after a system restart.

Guess you like

Origin blog.csdn.net/ryanzzzzz/article/details/131288601