Summary of Linux running level and all shutdown commands, and linux-level shutdown commands

Source: Internet
Author: User

Summary of Linux running level and all shutdown commands, and linux-level shutdown commands

What is a running level? Simply put, the running level is the function level currently running in the operating system. It allows some programs to start at one level, but does not start at another level.

Valid logon modes for Linux are 0 ~ There are a total of 10 types, but the limits of up to 6 types of UNIX systems are used, generally only 1 to 6 are valid. Different functions are available from 1 to 6.

/Etc/rc. d/init. d. Various scripts are placed in the file/etc/rc corresponding to each running level. d/rcN. d, select the script you want to run at this level, from/etc/rc. d/init. d.

The running-level file is defined under the/etc/inittab. This file is the main file found by the init program,

Init is the root process in Linux and the ancestor of all processes in the system. It is mainly used to generate processes based on a script program recorded in the/etc/inittab. This file is usually used to control the user logon mode.

The standard Linux operating level is 3 or 5. If it is 3, the system is in the multi-user State. If it is 5, the X Window System is running. If it is currently 3 or 5, and you reduce the running level to 2, init will execute the K45named script.

Different runtime levels are defined as follows: (refer to/etc/inittab in Linux)

The default running level is as follows:

0-Shutdown and machine shutdown.

1-single user mode. Similar to the security mode in Win9x

2-multi-user, but no NFS enters the multi-user mode without Network Services

3-full multi-user mode, which is a standard running level.

4-it is not used. Generally, it is not used. In some special cases, you can use it to do some things. For example, you can switch to this mode when the battery of your laptop is exhausted.

5-on the X11 console, log on to the graphical GUI mode.

6-Restart. The system restarts when you run init 6.

Init generally runs automatically when the system starts. It can also be called by the root user. It is used to switch the running status of the system.

The command format is init NUM <press enter>. NUM indicates any number from 1 to 6.

Two of the six modes are determined by the system:

0: Stop the system. Init 0 <press enter> is equivalent to halt <press enter> 〉.

6. restart the system. Init 6 <press enter> is equivalent to reboot <press enter> 〉.

In the terminal, We can type init <running level> to switch the running level for a certain purpose,

For example, input init 0 to shut down the system, and input init 6 to restart the system.

If you are using a text login screen, you are operating in Level 3. If you are using a graphical logon screen, you are operating in Level 5.

The default running level can be changed by modifying the/etc/inittab file. This file has a line similar to the following at the beginning:

Id: 5: initdefault:

Change the number in this row to the running level you want. Changes take effect only after the system is rebooted.

To change the running level immediately, run the telinit command, followed by the running level number. You must be the root user to use this command

Different running levels have different functions and should be set according to different situations.

For example, if the root password is lost, you can set the machine startup status to a single user.

Enter:

Init =/bin/sh rw

This allows the machine to enter runtime Level 1 and mount the root file system to read/write. It skips all system authentication, allows you to use the passwd program to change the root password, and then starts to a new running level.

Linux restart and shutdown commands

Both linux restart and shutdown are performed by the root user.

Restart command:

1. reboot

2. shutdown-r now restarts immediately

3. shutdown-r automatically restarts after 5 minutes (you can set the time by yourself)

4. shutdown-r restart at (time can be set by yourself)

Shutdown command:

1. init 0

2. Turn off the system and turn off the power of halt-p.

Halt-d shut down the system, but no record is left

3. poweroff

4. shutdown-h now shut down immediately

5. shutdown-h: shutdown automatically after 5 minutes (you can set the time by yourself)

Related Article

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.