Analysis of five Linux shutdown commands

Source: Internet
Author: User
(I) Shutdown

Shutdown parameter description:

[-T] before changing to another runlevel, tell init how long it will take to shut down [-R] restart the computer [-K]. It does not actually shut down, but only sends a warning signal to each executor [Login 〕 [-H] power off after Shutdown [halt] [-N] Don't use init, but shut down by yourself. You are not encouraged to use this option, and the consequences of this option are often not always the [-C] cancel current process you expected to cancel the currently running Shutdown program. Therefore, this option certainly does not have a time parameter, but you can enter a message for explanation, and this information will be sent to each user [-F] to ignore fsck [- f] force fsck [-time] to set the time before shutdown when restarting the computer [reboot]

Example:

Shutdown now # shutdown now + 2 # shutdown after 2 minutes shutdown at # shutdown at + 2 "the machine will shutdown" # shutdown after 2 minutes, and notify the online user to shutdown-H now immediately shut down, where now is equivalent to 0, halt, poweroff can also shut down, or the init 0 shutdown-H system will be shut down at tonight. shutdown-H + 10 system will be shut down automatically in 10 minutes. shutdown-T3-R now immediately restarts, but in the case of warning and deletion of processes, shutdown-k now 'Hey! Go away! Now... 'sends a warning message, but it does not actually shut down.

Use the shutdown command before shutting down the system. The system administrator will notify all logged-on users that the system will be shut down.
And the LOGIN Command will be frozen, that is, new users cannot log on again.
It is possible to directly shut down or wait for a certain period of time to shut down, or restart.
This is determined by the fact that all processes (processes) receive signals from the system (signal), such as vim, saving time for the documents being edited.

The shutdown execution principle is to send a signal [Signal] To the INIT program and require it to change the runlevel.

● Run level 0: Shutdown
● Run level 1: in single-user mode, only root users are allowed to maintain the system.
● Run level 2: multi-user mode, but NFS cannot be used (equivalent to network neighbors in Windows)
● Run level 3: text mode
● Run level 4: Undefined
● Run level 5: X Window
● Run level 6: restart

My habit is: shutdown-FH now

[root@Think ~]# who -r         run-level 5  2013-03-07 15:13                   last=S[root@Think ~]# runlevelN 5

(Ii) Halt

Halt parameter description:

[-N] prevents the sync system from calling. It is used after the root partition is repaired with fsck to prevent the kernel from overwriting the repaired super block with the old version of superblock [-W]. not a real restart or shutdown, but a wtmp (/var/log/wtmp) record [-D] Not a wtmp record [included in Option [-N 〕[- f] disable all network interfaces [-p] Before Force shutdown or restart [-I] for Shutdown Without calling shutdown. This option is the default option. That is, power off is called during shutdown.

In some versions, halt is continuously powered off, for example:

In fact, it has been shut down at this time, but the power supply has not been turned off. You need to manually turn off the power supply.

Halt is to call shutdown-H. When halt is executed, the application process is killed and sync is executed. After the file system completes the write operation, the kernel is stopped.


(Iii) reboot

The reboot process is similar to that of halt, but it causes host restart, while halt triggers shutdown.



(Iv) Init

Init is the ancestor of all processes, and its Process number is always 1. Therefore, sending a term signal to init will terminate all user processes, daemon processes, such as shutdown.
The init command uses the above runlevel



(V) poweroff

Soft link to halt

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.