Linux-related shutdown commands shutdown, halt, Poweroff, Init

Source: Internet
Author: User

Under Linux There are many commands to shut down, in the actual application they are still a little different, the system may have various effects, the next mainly will be under their specific usage and different.

Some of the more common restart and shutdown commands under Linux are: Shutdown, halt, Poweroff, Init, reboot


    1. Shutdown command (requires root permission, normal user can get permission via sudo)

      The shutdown command is recommended in these commands to enable shutdown and restart of the system by adding parameters.

      The shutdown performs shutdown and is sent to Init, requiring it to change the runlevel to shut down the machine. Shutdown or restart is actually a run-level adjustment, so you can also use Init to directly adjust the runlevel to shut down or restart.


It is safe to use the shutdown command to shut down the machine:

A Linux system is a multi-user operating system, and multiple processes are run in the background. It is very dangerous for the user to switch off the power directly, which may result in loss of system data and even damage to hardware devices.

When you add a time parameter using the shutdown command, you are notified that each logged-on user system is about to shut down, and that you can properly save the current work time to the user, thus avoiding the risk of a sudden forced shutdown of the process.

Shutdown the working process, the system administrator executes the shutdown command and sends a signal to Init requesting it to change the RunLevel runlevel.

RunLevel 0 is used to stop (halt)

RunLevel 6 is used to reactivate the (reboot) system

For detailed runlevel issues, you can view the/etc/inittab file, which is also listed below.


Shutdown parameter Description:

-T tells Init how long it will shut down before changing to another runlevel.
-R Restart Calculator.
-K does not really shut down, just sends a warning signal to each login (login).
-H Turn off the power (halt) after shutting down the machine.
-N Do not use init but to shut down the machine. The use of this option is discouraged, and the consequences of this option are often not always what you expect it to be.
-C Cancel Current process cancels the shutdown program that is currently executing. So this option certainly does not have a time parameter, but you can enter a message to interpret, and this information will be sent to each user.

Shutdown-r 2/now 2 minutes or restart the system immediately.

Shutdown-h 2/now 2 minutes or shut down the system immediately.


Example: System administrator performs shutdown-h 2, 2 minutes after shutdown, the system notifies the logged-on user that ASD is about to shut down as follows

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/FE/wKioL1Xxddeh7sA-AAB37-FvK7Q511.jpg "title=" 1.png " alt= "Wkiol1xxddeh7sa-aab37-fvk7q511.jpg"/>

Now the administrator would like to cancel the shutdown, you can use the-c parameter, and explain the reason for the cancellation

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/73/01/wKiom1Xxc6nj64qHAACLunWeHG4966.jpg "title=" 2.png " alt= "Wkiom1xxc6nj64qhaaclunwehg4966.jpg"/>

User ASD receives shutdown cancellation information

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/FE/wKioL1XxddfQG3FUAAC0QzvFuAw935.jpg "title=" 3.png " alt= "Wkiol1xxddfqg3fuaac0qzvfuaw935.jpg"/>

2.halt

Halt command quite with Shutdown-h now shuts down immediately, without notifying any user.

Parameters:
-N Do not write the memory data back to the hard drive before shutting down the machine.
-W doesn't really shut down, just writes the records to the/var/log/wtmp file.
-D does not write the record in the/var/log/wtmp file (-n This parameter contains the-D)-F: Force shutdown, do not call shutdown this command
-I stop all network-related devices first before shutting down the machine
-P when shutdown, by the way power off (Poweroff) action

3.poweroff

The Poweroff and halt commands are reboot soft connections, using the same

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/FE/wKioL1Xxd8zj5TX3AACHhOt05TM548.jpg "title=" 4.png " alt= "Wkiol1xxd8zj5tx3aachhot05tm548.jpg"/>

4. Init

Init is the ancestor of all processes and is one of the indispensable programs in Linux system operation. Its process number is always 1.

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

0 shutdown (never set the Initdefault to 0)

1 Single-User mode

2 Multi-user, no NFS

3 full Multi-user mode (standard run level)

4 Not used

5 X11 (Xwindow)

6 reboot (never set Initdefault to 6)

Shutdown shutdown is to request init to switch to RunLevel 0.

This article is from the "Dance Fish" blog, please be sure to keep this source http://ty1992.blog.51cto.com/7098269/1693628

Linux-related shutdown commands shutdown, halt, Poweroff, Init

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.