directory

One, foreword

Linux and CentOS

2.1 Relationship between Linux and CentOS

2.2 installing Centos7.0 on vmware

CentOS7 directory structure

3.1 Directory Structure

3.1.1 User Directories (/root directory and /home Directory)

3.1.2 /bin directory and /sbin directory

3.1.3 the/boot directory

3.1.4 / dev directory

3.1.5 / etc directory

3.1.6 /lib and /lib64 directories

3.1.7 / MNT Directory (/ Media Directory)

3.1.8 / opt directory

3.1.9 / proc directory

3.1.10 /run, / TMP, and /var directories

3.1.11 / SRV directory

3.1.12 / sys directory

3.2 Understand all directories in one sentence

Four, summary


One, foreword

In this article, we build the environment of Centos7.0 on vmware. We want to use the latest CentOS8.0, but the vmware15.5.1 can only support Centos7.0, I’m sorry, CentOS8.0 has to be installed directly on the computer. , focus on Linux directory structure, as a good recognition of CentOS tutorial.

Linux and CentOS

2.1 Relationship between Linux and CentOS

  The package name Management tool Managing a Single Software package Packing case The instance
Debian series .deb apt-get dpkg apt-get install xxx Debian, Ubuntu
Redhat series .rpm yum rpm yum -y  Redhat Enterprise Linux, FedoraCore, and CentOS

According to the preceding table, CentOS is the redhat Linux. It is included in Linux and a type of Linux.

2.2 installing Centos7.0 on vmware

There are a lot of tutorials on the Internet, but basically is to install Centos6.5, in fact, install CentOS7.0 is the same, or basically the mainstream version is the same, English difficult points will install the language set to “Chinese simplified”, absolutely can install, here skipped.

If you encounter problems during installation, you can solve the following problems of vmware: blog.csdn.net/qq_36963950…

CentOS7 directory structure

3.1 Directory Structure

In this picture, the author has just reinstalled the CentOS7 environment. After logging in, two kinds of users (ps: “#” for root user, “$” for common user), and blue for directory.

For a better understanding, I use my own understanding method to partition CentOS directory, and see the following picture:

    

Note: The user category catalog, system category catalog and application category catalog in the figure above are divided by the author for easy understanding, without any official authority.

3.1.1 User Directories (/root directory and /home Directory)

1. Contents and functions: /root is the home directory of administrator root, and /home is the home directory of common users.

2. Access permission: The /root directory is accessible only to the administrator root, but not to common users. The /home directory is accessible to administrator root and common users

Included subdirectories or subfiles: By default, the /root and /home/tester1 directories do not contain any valid files (there is an anaconda-ks. CFG file in the /root directory, which can be modified into an automatic installation script for automatic installation of the same system). In the future, there will be no other system files in these two directories (/root and /home/ username). These two directories are exclusively for users to put their own files. The directory structure is shown as follows:

3.1.2 /bin directory and /sbin directory

1. Contents and functions: Used for storing binary file directories

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles, as shown in the figure:

3.1.3 the/boot directory

1. Contents and Functions: the directory for storing files required for the startup of the Linux system

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles, as shown in the figure:

3.1.4 / dev directory

1. Contents and Functions: A directory used to store Linux device files. Accessing a file in this directory is equivalent to accessing a device.

Linux follows the Unix style of recognizing all devices as a file, and users can easily access these external devices, and access a file, a directory is no different. Because this directory contains all the peripherals used in Linux, it’s not a driver for the peripherals, it’s actually a port to access them.

Linux devices can be divided into two types: block device files (b) and character device files (C).

Character device: no buffering and sequential access only

Block device: buffered and accessible randomly (out of order)

Each device file must have a primary/secondary device number. Devices with the same primary device number are the same device and use the same driver (although the current kernel allows multiple drivers to share the same primary device number). However, most devices still follow the principle that one driver corresponds to one main device number. You can run the cat /proc/devices command to view the main device ID of the loaded device driver.

P: how are subdirectories and subfiles (i.e. devices) created under /dev?

Devf or udev will automatically create it for you.

Kobject is the basis of the sysFS file system, and Udev monitors sysFS to retrieve newly created devices.

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles

Here, I explain each subdirectory or subfile under /dev in CentOS7 according to my own VIRTUAL machine, as shown in the figure:

/dev = /dev

A few important points about the /dev directory

1, /dev/cdrom soft link

/dev/cdrom: /dev/sr0:

/dev/sr0 is the device name of the CD/DVD-ROM drive, and /dev/cdrom is the CD/DVD-ROM drive

Cdrom is a soft link to sr0, you can use ll /dev/cdrom and ll /dev/sr0 to see what is displayed

The /dev/block directory contains a block device.

                         

Yes, each entry in /dev/block not only gives a list of block devices, but can also be defined as the location to the device, as shown in the figure above, first to the /dev directory, and then to the corresponding device. (Note: the /dev/char directory holds character devices, but there are too many to demonstrate.)

3, about /de/input directory

                      

The /dev/input directory is used to store input devices. Here is a screenshot of the author’s VIRTUAL machine.

4. Emphasis on HDA2 sDA3

Hda refers to the IDE interface, hDA refers to the first hard disk, HDB refers to the second hard disk, etc. Sda refers to SATA disks, SDA refers to the first disk, SDB refers to the second disk, and so on. Hda2 represents the second partition of the first IDE disk, sda3 represents the third partition of the first SATA disk,

Note: In number four, you number disks by A, B, and C, and you number partitions by 1, 2, 3. In fact, Linux, including Redhat and Debian, do this, sometimes A, B, and C, sometimes 1, 2, 3, as you’ll see, It’s basically a, B, C, or 1, 2, 3 so you can think about whether this is a number or not.

3.1.5 / etc directory

1. Contents and Functions: This directory is used to store system configuration files. You are not advised to store executable files in this directory.

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles, as shown in the figure:

The figure above shows the structure of /etc directory and its explanation.

3.1.6 /lib and /lib64 directories

1, content and function: used to store the system used function library directory, program in the execution process, need to call some extra parameters need the help of the function library, the more important directory is /lib/modules.

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles, as shown in the figure:

/lib /lib64 /lib64 /lib64 /lib64 /lib64 /lib64 /lib64 /lib64 /lib64 /lib64

/usr/local = /usr/ root = /usr/local = /usr/ root = /usr/local

Question: What are the differences between/root, /usr, /usr/local, and /bin/sbin/lib/lib64/etc?

/bin /sbin /lib /lib64 /etc/root directory /bin /sbin /lib /lib64 /etc/root directory /bin /sbin /lib /lib64 /etc The /lib64 directory is deleted and the VM is unavailable

The /usr directory contains the Unix Software Resource, which stands for ****. Unix system Software resources are shared by users. The system Software is installed in this directory and third-party Software installed by users is shared by users. /usr/bin/usr/sbin/usr/lib/usr/lib64/usr/libexec /usr/etc It is better to place dependencies under /usr/lib and configure them under /usr/etc

The /usr/local directory is the default directory for installing local programs. This is the recommended directory for CentOS users to install software. Therefore, it is best to get into the habit of installing your own software in /usr/local directory and keep the same habit. If the software is installed in /usr/local, place the dependency packages in /usr/local/lib and configure them in /usr/local/etc

The /usr/bin directory is used by all users. The /usr/bin directory is used by the current user

Ps: Regarding the system administrator in the figure above, what is a system administrator?

In Linux, there are only two types of independent users: root user and common user. These two types of users can operate sbin and /usr/sbin directories, that is, the system administrator is not an independent user.

3.1.7 / MNT Directory (/ Media Directory)

1. Contents and Functions: The default directory for mounting disks.

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles: by default, the/MNT directory does not contain any files or directories, as shown in the figure:

                 

To mount a device, create a /cdrom directory under the current/MNT directory and mount it to/MNT /cdrom. (PS: The CD-ROM is usually mounted under/MNT /cdrom, but it is not necessary. You can mount it anywhere.)

Related questions: / MNT directory, /media directory, /dev directory three differences

/ MNT is a directory used by system administrators to manually mount some temporary media devices.

/medai is an automatic mount directory. For example, if our USB flash drive is inserted into Ubuntu and automatically mounted, a directory will be generated under /media. This directory is the directory where the USB flash drive is located, or the file.

/dev is not a driver to store the device, but an interface to access files on the external device. For example, after inserting the USB flash drive into the Linux system, run fdisk -l to check the partition and display the file /dev/sda1. To mount the USB flash drive to/MNT /usb1, run mount /dev/sda1 / MNT /usb1.

/ MNT is mounted manually, /media is mounted automatically, and /dev is the device interface.

3.1.8 / opt directory

1. Contents and functions: The directory for the host to install additional software.

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles

By default, the/MNT directory starts with no files or directories, as shown in the figure below:

     

The /opt directory will not store any system items, because this directory is intended for users to store some spare items, software packages and so on.

3.1.9 / proc directory

1. Contents and functions: The data in this directory are stored in memory, such as system core, external devices, and network status. As the data is stored in memory, it does not occupy disk space

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles

As shown in figure:

The /proc directory contains information about processes.

3.1.10 /run, / TMP, and /var directories

1. Contents and functions: These three directories are used to store temporary data at runtime. The full name of the directory is run, which is used to store temporary data at runtime. / TMP directory: Temporary. It is a directory for storing files temporarily for ordinary users or programs that are running. /var directory: variable, used to store files that change frequently

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles

For the /run directory: temporary data at runtime, the subdirectories and subfiles of this directory are meaningless.

For the/TMP directory: because all files in this directory will be deleted when the system restarts, the subdirectories and subfiles of this directory are meaningless.

For the /var directory, see the following figure:

3.1.11 / SRV directory

1. Contents and Functions: Service is a directory for storing data that needs to be accessed after the service is started

2, access rights: administrator root and common users can access

3. Contained subdirectories or subfiles: There is no directory in this directory by default.

3.1.12 / sys directory

Contents and Functions: /sys directory: the full name of the directory is system, which is used to store file systems

2, access rights: administrator root and common users can access

3. Included subdirectories or subfiles: store file systems, as shown in the figure:

                  

User-level operations are generally unavailable. Skip this operation.

3.2 Understand all directories in one sentence

Linux directories are generally divided into three categories: user category directory, system category directory, application category directory (this division is only for the convenience of the author to understand the division, without any official authority). There are two user directories. The root directory is used by the root account, and the home directory is used by common users. Each user in the home directory has a command directory with a user name, which is the directory of the user. System class directories include /bin for binary executable files, /boot for boot, /sbin for system management configuration, /etc for system configuration files, /lib and /lib64 for function libraries, /dev for devices, / MNT for mounts, and /media for mounts. The /sys directory is for file systems, the /proc directory is for process information, and the/SVC directory is for service information. The/TMP, /run, and /var directories are all run-time changes. The /usr and /opt directories are intended for user use.

Four, summary

This article constructs CentOS 7.0 environment on vmware, focuses on the Linux directory structure, as a good recognition of CentOS tutorial.

Play code every day, progress every day!