Home >Operation and Maintenance >Linux Operation and Maintenance >What is the difference between shutdown commands in linux

What is the difference between shutdown commands in linux

王林
王林Original
2020-07-02 16:07:392926browse

The difference between the shutdown commands in Linux is: when the shutdown command is executed, the system will notify all logged-in users that the system is about to shut down; when the halt command is executed, the kernel stops after the file system write operation is completed; the init command is used to switch The running level of the system, [init 0] means shutdown.

What is the difference between shutdown commands in linux

The shutdown commands in Linux include shutdown, halt and init. They can all achieve the purpose of shutdown, but the internal working process of each command is different. Let’s introduce them respectively:

(recommended learning: linux tutorial)

1. Use shutdown

shutdown command to safely shut down a Linux system.

Because Linux is different from Windows and has many processes running in the background, forced shutdown may cause data loss of the process, put the system in an unstable state, and even damage hardware devices.

When executing the shutdown command, the system will notify all logged-in users that the system will be shut down, and the login command will be frozen, that is, new users can no longer log in to the system.

The essence of the shutdown command is to send a signal to the init program, requiring it to switch the run level of the system (Runlevel).

The running levels of the system include:

  • 0: Shut down the system

  • 1: Single user mode, if not shutdown If the command is executed directly by specifying the -h or -r parameter, it will switch to this run level by default

  • 2: Multi-user mode (NFS is not supported)

  • 3: Multi-user mode (supports NFS), this running level is commonly used

  • 5: Multi-user mode (GUI mode)

  • 6: Restart the system

2. halt

halt is the simplest shutdown command, which actually calls shutdown - h command. When halt is executed, the application process is killed and the kernel is stopped after the file system write operation is completed.

Some parameters of the halt command are as follows:

  • [-f] Force shutdown or restart without calling shutdown

  • [ -i] Before shutting down or restarting, shut down all network interfaces

  • [-p] Call poweroff when shutting down, this option is the default option

3. init

init is the ancestor of all processes, and its process number is always 1.

init is used to switch the running level of the system, and the switching work is completed immediately.

The init 0 command is used to immediately switch the system running level to 0, that is, shut down; the init 6 command is used to switch the system running level to 6, that is, to restart.

The above is the detailed content of What is the difference between shutdown commands in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more