Linux from entry to abandonment (2) directory structure

First, the difference between the Linux and Windows system directory structure

Before understanding the linux directory structure, you must first be clear that the difference between the Linux directory and the Windows directory may not be much different from the general operation experience, but it is completely different from their implementation mechanism. .

1) Windows directory structure diagram:

2) Linux directory structure diagram:

 A difference is reflected in the relationship between directories and storage media (disk, memory, DVD, etc.). In the past, Windows has always been based on storage media, mainly drive letters (C drive, D drive...) and partitions. To achieve file management, and then the directory is below, the directory is not so important, and user files other than system files are placed anywhere in any directory. It doesn't matter much. Therefore, usually after Windows has been used for a period of time, the file directory on the disk will appear disorganized (except for a few users who are good at organizing). However, UNIX/Linux is just the opposite. UNIX is mainly based on directories, and Linux also inherits this excellent feature. Linux builds the entire system in the form of a tree-shaped directory structure, which can be understood as the skeleton of a user-operable operating system. Although essentially both the directory structure and the operating system kernel are stored on the disk, logically speaking, the Linux disk is "mounted" (mounted) on the directory, and each directory can not only use local disk partitions file system, you can also use a file system on the network. For example, a network file system (Network File System, NFS) server can be used to load a specific directory, etc.

Second, the basic introduction of Linux directory

1) The Linux file system adopts a hierarchical tree-like directory structure. The top level of the structure is the root directory "/", and then other directories are created in this directory.

  • bin : bin is the abbreviation of Binaries (binary files), this directory stores the most frequently used commands.

  • /boot: Stored here are some core files used when starting Linux, including some connection files and image files.

  • /dev: dev is the abbreviation of Device (device), this directory stores the external devices of Linux, and the way to access devices in Linux is the same as the way to access files.

  • /etc: etc is short for Etcetera (etc.), this directory is used to store all configuration files and subdirectories required for system management.

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

  • /lib : lib is the abbreviation of Library (library) This directory stores the most basic dynamic link shared library of the system, and its function is similar to the DLL file in Windows. Almost all applications need to use these shared libraries.

  • /lost+found : This directory is usually empty. When the system is shut down illegally, some files are stored here.

  • /media : The linux system will automatically identify some devices, such as U disk, CD-ROM, etc. After identification, Linux will mount the identified device to this directory.

  • /mnt : This directory is provided by the system to allow users to temporarily mount other file systems. We can mount the CD-ROM drive on /mnt/, and then enter this directory to view the contents of the CD-ROM drive.

  • /opt : opt is an abbreviation for optional, which is the directory where additional software is installed on the host. For example, if you install an ORACLE database, you can put it in this directory. Default is empty.

  • /proc : proc is the abbreviation of Processes (process), /proc is a pseudo file system (that is, a virtual file system), which stores a series of special files of the current kernel running state. This directory is a virtual directory, which Is the mapping of system memory, we can get system information by directly accessing this directory. The content of this directory is not on the hard disk but in the memory. We can also directly modify some files in it. For example, we can block the ping command of the host through the following command, so that others cannot ping your machine:

  • /root : This directory is the home directory of the system administrator, also known as the super-authorized user.

  • /sbin : s means Super User, which is the abbreviation of Superuser Binaries (Super User Binaries), which stores the system management programs used by system administrators.

  • /selinux : This directory is unique to Redhat/CentOS. Selinux is a security mechanism, similar to the Windows firewall, but this mechanism is more complicated. This directory is used to store selinux-related files.

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

  • /sys

    This is a big change in the Linux 2.6 kernel. A new file system sysfs in the 2.6 kernel is installed in this directory.

    The sysfs file system integrates the information of the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo-terminals.

    The filesystem is a visual reflection of the kernel device tree.

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

  • /tmp : tmp is the abbreviation of temporary (temporary) This directory is used to store some temporary files.

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

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

  • /usr/sbin: The more advanced management programs and system daemons used by superusers.

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

  • /var : var is the abbreviation of variable. This directory stores things that are constantly expanding. We are used to placing those frequently modified directories in this directory. Includes various log files.

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

In the Linux system, there are several directories that are more important. Usually, you need to be careful not to delete or arbitrarily change the internal files.

/etc: As mentioned above, this is the configuration file in the system. If you change a file in this directory, it may cause the system to fail to start.

/bin, /sbin, /usr/bin, /usr/sbin: This is the default directory where the executable files are placed by the system. For example, ls is in the /bin/ls directory.

It is worth mentioning that /bin and /usr/bin are instructions for system users (general users except root), while /sbin and /usr/sbin are instructions for root.

/var: This is a very important directory. There are many programs running on the system, so each program will generate corresponding logs, and these logs will be recorded in this directory, specifically in the /var/log directory, in addition The default placement of mail is also here .

Guess you like

Origin blog.csdn.net/OMGcome/article/details/124262805