Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of directory structure and boot flow of Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the "Linux directory structure and boot process details" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

Catalogue

0x01 Linux important directory structure

0x02 Linux startup process

0x01 Linux important directory structure

/ bin

The user's commands are all here.

Use the which command to view the path of the command

/ boot

The directory where the Linux kernel and system bootstrap are located

/ dev

The directory of device files, hard drive, sound card and so on are all here.

/ etc

The directory of the software's configuration files and the directory of the software startup program

/ home

The home directory of an ordinary user

/ root

Root user's home directory

/ lib

The shared file library files and kernel module directories needed to start the system and run the command

/ lost+found

When the system crashes, some files are stored here, and you can restore them through some commands.

/ mnt

Temporary mount point, which is used to temporarily mount a storage device. In order to use the inserted device, the device must be mounted before it can be accessed.

Mount / dev/cdrom / mnt

Mount the device in dev to the mnt directory before you can access it. For example, when you plug in the storage device, it is like a prison. You cannot enter without a door. Only after you mount it to the mnt directory, you can open a door before you can enter the storage device. Use the following to cancel the mount point, which is equivalent to removing the door.

Umount / mnt

/ opt

Optional directory, some software will also be installed here, our own compiled software packages, can also be placed in this directory

/ sbin

System administrator-related commands, / bin is the command of ordinary users

/ tmp

Temporary file directory, special permissions, equivalent to the Windows Recycle Bin, before a friend installed the program to this directory, but also wonder why there is no more after the restart.

/ usr

The directory where the program is stored

/ usr/local: default software installation directory / usr/src: program source code directory

/ var

A changing catalogue in which the contents are constantly changing

/ var/log: directory where Syslog is stored / var/log/messages: Syslog path / var/lib: path where library files are stored

/ proc

When the system is running, the process information and kernel information are stored here, such as cpu, hard disk, memory, and so on.

/ proc/loadavg: system load / proc/meminfo: system memory information / proc/cpuinfo: system cpu information / proc/mounts: system mount information

Next, when it comes to the startup process of Linux, there are two more files that need to be clarified.

I.

/ etc/fstab

Configure files to be automatically mounted by boot devices

As mentioned earlier in the / mnt directory, access can only be carried out after the hard disk is mounted to the mount point, but we have not manually mounted the Linux. Without mounting, we cannot access it, so how does the system start?

Because this file automatically mounts the boot device, we can automatically mount the file by changing the file. We must be careful not to miswrite the contents of the file. If it is written wrong, the Linux system may not be able to start, because after the error is encountered in the mount, it will not continue to be executed. In order to avoid this situation, the last value must be set to 0. No disk check, if set to 1 or 2, may cause the device to fail to boot.

There are six columns, from left to right:

The device to be mounted, the mount point, the file system format at the time of mount, the parameters at the time of mount, whether to back up, whether to check the disk

II.

Linux run level

Linux has seven runlevels, which are

0: shutdown 1: single user mode 2: multiuser mode without NFS (network file system) 3: complete multiuser mode (commonly used) 4: unused, reserved 5: graphical mode 6: restart

Generally speaking, the default is 3 mode.

Use init to switch the current run level

Use runlevel to view the current runlevel

The first is the last run level, and the second is the current run level

When you choose level 2 execution, all the files under / etc/rc2.d will be executed once.

First of all, at boot time, the BIOS on the motherboard will be loaded, and then the hardware self-test will be started, and if there is a problem, it will not continue to boot.

The boot program will then be handed over to the hard disk, that is, the MBR boot in the figure, and a portion of the storage space in the hard disk will be loaded, which is the main boot program.

Then load Linux's GRUB menu

After waiting for the kernel to load, the INIT process, the first process of Linux, will be run. At this time, the / etc/inittab file will be read. This file sets the level at which Linux starts, and after that, all programs below the corresponding level, that is, all files under the folder of the run level we mentioned above, will be loaded.

At the same time, the basic configuration program / etc/rc.d/rc.sysinit of Linux will be loaded, which contains the necessary things such as hostname, device, network card, etc.

PS: some systems do not have a directory for rc.d, so all the files in the rcS.d directory are executed.

At this point, Linux has been started and completed.

This is the end of the content of "detailed explanation of the directory structure and boot process of Linux". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report