Linux Run level detailed

Source: Internet
Author: User

For advanced users who are under the Dos/win9x/nt platform, Linux appears to be a monster. No Config.sys, no Autoexec.bat, and a personal feature of the machine configuration does not know where to start.

It should be explained that many people think that Linux is a clone of Unix, but this is not fair to Linux. Linux is more open and powerful than UNIX. We should call it gnu/linux.

When Linux starts, it runs a program called Init, and then it launches the following tasks, including multi-user environments, networks, and so on.

So, what exactly is a run-level? Simply put, the run level is the functional level that the operating system is currently running. This level is from 1 to 6 and has different functions. These levels are specified in the/etc/inittab file. This file is the main file that the INIT program looks for, and the first service to run is those files that are placed in the/ETC/RC.D directory.

In most Linux distributions, the startup script is located in/etc/rc.d/init.d. These scripts are connected to the/ETC/RC.D/RCN.D directory by the LN command. (n here is the run level 0-6) For example/etc/rc.d/rc2.d the following s10network is connected to the network script under/ETC/RC.D/INIT.D.

Therefore, we can know that rc2.d the following file is related to the run Level 2. The beginning of the file s for start is the start service meaning, the following number 10 is the order of the boot. For example, in the same directory, you can also see s80postfix this file, 80 is the order after 10, because there is no network startup, start Postfix is not any effect.

Look at/etc/rc.d/rc3.d again, you can see the file S60nfslock, but this file does not exist in the/ETC/RC.D/RC2.D directory. NFS uses this file, which is typically used in a multiuser environment, so it is placed in the RC3.D directory.

In addition,/ETC/RC.D/RC2.D can also see those files that begin with K, such as/etc/rc.d/rc2.d/k45named,k for Kill.

The standard Linux run level is 3 or 5, and if it is 3, the system is in multi-user state. If it is 5, it is running the X Window system. If you are currently 3 or 5, and you have reduced the run level to 2, Init will execute the k45named script.

The different run levels are defined as follows: (refer to/etc/inittab in red Hat Linux)

# The default run level, the level used by RHS is as follows:
# 0-Stop (never set the Initdefault to 0)
# 1-Single user mode
# 2-Multi-user, but no NFS
# 3-Full multi-user mode
# 4-No use
# 5-x11
# 6-Reboot (never set Initdefault to 6)

# A detailed explanation of each run level:
0 for downtime, the machine shuts down.
1 is a single-user mode, similar to the safe mode under Win9x.
2 is multi-user mode, but there is no NFS support.
3 is the full multi-user mode and is the standard run level.
4 generally not, in some special cases you can use it to do something. For example, you can switch to this mode to do some setup when your laptop's battery is running out.
5 is X11, into the X Window System.
6 Restart, the init 6 machine will restart.

Different run levels have different uses, and should be set according to their own different situations. For example, if you lose the root password, you can set the machine to boot into a single-user state. At the Lilo prompt after startup, enter:

Init=/bin/sh RW

You can get the machine into run Level 1 and hang the root file system as read-write. It skips all system certifications, lets you use the passwd program to change the root password, and then launches to a new run level.

Linux run-level detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.