Linux shutdown and restart commands [go]

Source: Internet
Author: User

If you are in a hurry to shut down or restart the session, then the shutdown is init 0, restart is init 6 or reboot



The common shutdown and restart commands in Linux are shutdown, halt, reboot, and Init, all of which can be used for shutdown and restart purposes, but the internal work process for each command is different, as described below.



1. Shutdown



The shutdown command is used to safely shut down the Linux system. It is dangerous for some users to turn Linux off using a direct power-off. Because Linux, unlike Windows, runs many processes in the background, forcing a shutdown can cause data loss to the process, leave the system in an unstable state, and even damage the hardware device.



when you execute the shutdown command, the system notifies all logged-on users that the system is about to close, and the login command is frozen, meaning that the new user can no longer log on to the system. Use the shutdown command to shut down the system directly, or to delay the specified time before shutting down the system and restarting. Delay the specified time before shutting down the system, allowing the user time to store the files currently being processed and to close the open program.



some of the parameters of the shutdown command are as follows:



[-T] Specifies the length of time after which the system is shut down



[-R] Reboot system



[-K] does not really shut down, just send a warning signal to each logged-on user



[-h] shutdown system (halt)



the essence of the shutdown command is to send a signal (signal) to the INIT program, requiring it to switch the operating level of the system (Runlevel). The operating levels of the system include:



0: Shut down the system



1: Single-user mode, if executed directly without specifying the-h or-R parameters for the shutdown command, the default is to switch to this runlevel



2: Multi-user mode (NFS not supported)



3: Multi-user Mode (NFS supported), commonly used in this kind of operation level



5: Multi-user mode (GUI mode)



6: Reboot the system



2. Halt



Halt is the simplest shutdown command, which is actually called the shutdown-h command. When halt executes, the application process is killed and the kernel is stopped after the file system write operation is complete.



some of the parameters of the halt command are as follows:



[-f] forced shutdown or restart without calling shutdown



[-i] turn off all network interfaces before shutting down or restarting



[-p] Call Poweroff when shutdown, this option is the default option



3.reboot



reboot work in a similar way to halt, and its role is to reboot, while Halt is shutdown. The parameters are similar to halt.



4.init



Init is the ancestor of all processes whose process number is always 1. Init is used to switch the operating level of the system, and the job of switching is done immediately. The init 0 command is used to immediately switch the system RunLevel to 0, which is shutdown, and the init 6 command is used to switch the system RunLevel to 6, which is a reboot.

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.