Linux Down Command Difference (halt,poweroff,reboot,shutdown,init) __linux

Source: Internet
Author: User

Some common shutdown/restart commands under Linux.

1.shutdown

The shutdown command shuts down the system securely.
It is very dangerous for some users to turn off Linux by simply breaking the power off. Because Linux differs from windows in that it runs many processes in the background, forcing a shutdown can cause data loss in the process, leaving the system in an unstable state, or even damaging hardware devices in some systems. Using the shutdown command before the system shuts down, the system administrator notifies all logged-in 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 the machine directly or delay it for a certain time, and it may reboot. This is determined by the signal (signal) that all process (process) will receive the system delivery. This lets programs like VI have time to store documents that are currently being edited, and programs like Mail (mail) and news (news) can leave and so on.
Shutdown performs its work by sending signals (signal) to the INIT program, requiring it to change runlevel. RunLevel 0 is used to stop (halt),runlevel 6 is used to reactivate the (reboot) system, while RunLevel 1 is used to allow the system to enter the state that management can perform; This is a preset, assuming no-H and no-R parameter to shutdown. To find out what you did during the downtime (halt) or reboot (reboot), you can see the runlevels related information in this file/etc/inittab.

Shutdown parameter Description:

[-T] tell Init how long to shut down before changing to another runlevel.
[-R] to restart the 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 computer.
[-n] do not need to init, but to shut down the machine. Use of this option is discouraged, and the consequences of this option are often not always what you expect.
[-c] Cancel current process cancels the currently executing shutdown program. 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 while restarting Calculator (reboot).
[-f] Forces fsck when the calculator (reboot) is restarted.
[-time] Sets the time before the shutdown (shutdown).

For example:

/sbin/shutdown-h now-----immediately shut down the machine;
/sbin/shutdown-h 20:49----20:49 Separation Machine
/sbin/shutdown-h +10-----10 minutes after shutdown
/sbin/shutdown-r now---immediate reboot
/sbin/shutdown-r +10 ' The system'll reboot '----10 reboot and notify each logged-on user in minutes
/sbin/shutdown-k now ' the system would reboot '--notification to each logged-on user does not really shut down

2.halt--the simplest shutdown command

In fact, halt is called shutdown-h. Halt executes, kills the application process, performs the sync system call, and stops the kernel after the file system write operation completes.

Parameter description:

[-n] Prevents sync system calls, which are used after patching the root partition with fsck to prevent the kernel from overwriting the patched super blocks with the old version of the Super Block (superblock).

[-W] is not a real reboot or shutdown, just write Wtmp(/var/log/wtmp) records.
[-d] does not write Wtmp records (already included in options [-n]).
[-f] forced shutdown or reboot without invoking shutdown.
[-i] turn off all network interfaces before shutting down (or rebooting).
[-p] This option is the default option. is to call Poweroff when shutdown.

3.reboot

Reboot's work process is almost the same as halt, but it triggers a host reboot, and Halt is shutdown. Its parameters are not much different from the halt.

4.init

Init is the ancestor of all processes, and its process number is always 1, so sending term signals to init terminates all user processes ﹑ daemons, and so on. Shutdown is the use of this mechanism. Init defines 8 run levels (RunLevel), and init 0 restarts,init1 for shutdown. There is no longer a narrative about init that can be lengthy. There are also telinit commands that can change the running level of init, such as,telinit-is, which allows the system to enter Single-user mode, and does not have the information and latency to use shutdown.

5.poweroff

The shutdown is not recommended in multi-user mode (RunLevel 3).

. Turn from Baidu know.

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.