Linux shutdown command Summary

Source: Internet
Author: User

Common shutdown commands in linux include shutdown, halt, poweroff, and init. Restart Commands include reboot. The following describes some common shutdown commands and their differences and usage.

First, let's take a look at some commonly used shutdown commands in linux.

Shutdown command:

1. Shut down halt immediately
2. Power off immediately
3. shutdown-h now shut down immediately (used by the root user)
4. shutdown-h: shutdown automatically 10 minutes later

Note: If you use the shutdown command to set shutdown, you can use the shutdown-c command to cancel the restart.

Restart command:

1. reboot
2. shutdown-r now restarts immediately (used by the root user)
3. shutdown-r restarts automatically after 10 minutes (used by root users)
4. shutdown-r restart at (for root users)

Note: If you use the shutdown command to set the restart, you can use the shutdown-c command to cancel the restart.

Next, let's take a look at the differences and usage of these linux shutdown commands.

1. shutdown safe shutdown command

For the shutdown command, it is a safe command recommended by everyone. It can be shut down or restarted through the cooperation of the-h or-r parameter. However, in linux, you can only use this command if you have the root permission. Therefore, although we recommend using this command, it is really inconvenient to use it: Do you want to use this command? Get the root permission first. Shutdown: send a signal to init to change the running level to shut down the system. Shutdown or restart is actually an adjustment of the running level, so we can also use init to directly adjust the running level for shutdown or restart. When you use this command, the machine is immediately shut down or restarted. It also requires the root permission.

So why does the shutdown command safely shut down the system?

In reality, it is very dangerous for some users to shut down linux by directly disconnecting the power supply. Because linux and windows run many processes in the background, forced shutdown may lead to data loss in the process, making the system unstable. In some systems, hardware is damaged. When the shutdown command is used before the system is shut down, the system administrator will notify all logged-on users that the system will be shut down. The login command is frozen, meaning that 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 signal that all processes receive from the system [signal.

Shutdown is to send a signal to the init program and ask it to change the runlevel. Runlevel 0 is used to stop [halt], runlevel 6 is used to reactivate the [reboot] system, and runlevel 1 is used to bring the system into a State that can be managed, this is the default one. Assume that no-h or-r parameter is set to shutdown. Do you want to know what actions are performed during the shutdown (halt) or re-boot (reboot) process? You can view the runlevels related information in the/etc/inittab file.

Shutdown parameter description:

[-T] before changing to another runlevel, tell init how long it will take to shut down.
[-R] restart the calculator.
[-K] does not actually shut down, but sends a warning signal to each consumer [login 〕.
[-H] power off after Shutdown [halt 〕.
[-N] shut down by yourself instead of init. You are not encouraged to use this option, and the consequences of this option are not always what you expected.
[-C] cancel current process cancels 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] Ignore fsck when restarting calculator [reboot.
[-F] forces The fsck when restarting the calculator [reboot.
[-Time] set the time before shutdown.
     
2. The simplest command to shut down halt

When you use the halt command to shut down the instance, shutdown-h is actually called. When halt is executed, the application process is killed. After the sync system calls the file system, the kernel is stopped after the write operation is completed.

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] is not a real restart or shutdown, but a record for wtmp (/var/log/wtmp.
[-D] Do not write the wtmp record [included in Option [-n 〕.
[-F] Force shutdown or restart without calling shutdown.
[-I] disable all network interfaces before shutting down (or restarting.
[-P] this option is the default option. It is called poweroff when shutdown.

3. Commonly Used power-off commands

For poweroff, It is a link to the halt command online. The basic usage is similar to that of halt.

4. init

Init is the ancestor of all processes. It is one of the indispensable programs in Linux system operations. The process number is always 1. Therefore, sending a TERM signal to init will terminate all user processes and daemon processes. Shutdown uses this mechanism. Init defines eight runlevels. init 0 indicates shutdown, and init 1 indicates restart.

5. reboot restart command

The reboot process is similar to that of halt. However, it causes host restart, while halt causes shutdown. Its parameters are similar to those of halt.

Articles you may be interested in
  • Graphic tutorial on common basic commands in Unix/Linux
  • Summary of linux Command for viewing File Content
  • Linux chmod (file or folder permission setting) command parameters and Usage Details
  • Create a folder (mkdir) command in linux
  • Delete files in linux. Detailed explanation of the rm command for folder commands
  • Linux File Creation (touch) command details
  • How many lines of files can be viewed in linux?
  • Linux clear screen command (clear, reset)

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.