Linux Shutdown/restart command summary

Source: Internet
Author: User

Common Linux shutdown commands are: Shutdown, halt, Poweroff, Init, and the restart command: reboot. The following article mainly introduces some common shutdown commands and various shutdown commands between the differences and specific usage.

First look at some of the more commonly used Linux shutdown commands

Shutdown command:

1, halt immediately shut down the Machine 2, Poweroff immediately shut down the Machine 3, Shutdown-h now immediately shutdown (root user) 4, shutdown-h 10 10 minutes after the automatic shutdown if it is set by the shutdown command shutdown, you can use the Shutdo wn-c Command Cancel restart

Restart command:

1, reboot 2, Shutdown-r now restart (root user) 3, shutdown-r 10 10-minute automatic restart (root user) 4, shutdown-r 20:35 restart at 20:35 time (root User) You can use the Shutdown-c command to cancel the restart if the restart is set by the shutdown command

Let's take a look at the differences between these specific shutdown commands for Linux and their respective usage

1.shutdown Secure Shutdown Command

For the shutdown command, it is a safe command recommended by everyone to complete the shutdown or restart with the parameter-H or-R mates. However, you can use this command only if you have root privileges on a Linux system. So, although it is recommended to use this command, this command is really inconvenient: do you want to use this command? Get root permission first. 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 we can also use init to adjust the runlevel directly to shut down or restart the machine. When using this command, the machine shuts down or restarts immediately. It also requires root privileges.

So why is it that the shutdown command shuts down the system safely?

It is dangerous for some users to turn Linux off using a direct power-off. Because Linux differs from Windows, many processes are running in the background, forcing a shutdown can cause data loss to the process and leave the system in an unstable state. Even in some systems, hardware devices can be damaged. With the shutdown command before the system shuts down, the system administrator notifies all logged-on users that the system will be closed. And the login command is frozen, that is, the new user can no longer log in. It is possible to shut down directly or delay a certain amount of time, or it may be a reboot. This is determined by all process (process) receiving the signal (signal) the system arrives at.

Shutdown performs its job of sending a signal (signal) to the INIT program, requiring it to change the runlevel. RunLevel 0 is used to shut down (halt),runlevel 6 is used to reactivate the (reboot) system, while RunLevel 1 is used to get the system into the state that the management work can take, which is preset. Assume that there is no-H and no-R parameter to shutdown. Want to know what to do during a shutdown (halt) or reboot (reboot)? You can see these runlevels related information in this document/ETC/INITTAB.

Shutdown parameter Description:

[-T] tell Init how long it will shut down before changing to another runlevel. [-R] Restart calculator. [-K] does not really shut down, just send 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. [-f] ignores fsck when restarting the calculator (reboot). [-f] forces fsck to restart the calculator (reboot).      [-time] Sets the time before the shutdown (shutdown).

2.halt The simplest shutdown command

When the halt command is used to shut down the machine, the actual call is shutdown-h. The halt execution will kill the application process, and the kernel will stop after the sync system call file system write is complete.

Halt parameter Description:

[-n] prevents the sync system from being called, it is used after patching the root partition with fsck to prevent the kernel from overwriting the patched super block with the old version of the Super Block (superblock). [-W] is not a real restart or shutdown, just write Wtmp(/var/log/wtmp) records. [-d] does not write wtmp record (included in option [-n]). [-f] does not invoke shutdown and forces shutdown or restart. [-i] turn off all network interfaces before shutting down (or restarting). [-p] This option is the default option. is to call Poweroff when shutting down the machine.

3.poweroff Common shutdown commands

For Poweroff, Online said it is halt command link, basic usage and halt almost, here is not much to say.

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, so sending a term signal to init terminates all user processes, daemons, and so on. Shutdown is the use of this mechanism. Init defines 8 runlevel (runlevel), Init 0 is off, and init 1 restarts.

5.reboot Restart command

Reboot's working process is almost as halt. However, it is caused by a host reboot, and Halt is shutdown. Its parameters are not much different from the halt.

Original: http://www.cnblogs.com/wanggd/archive/2013/07/08/3177398.html

Linux Shutdown/restart command summary

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.