What is the difference between linux shutdown commands

coldplay.xixi
Release: 2023-01-04 09:37:55
Original
4016 people have browsed it

The difference between Linux shutdown commands: 1. The shutdown command is used to safely shut down the Linux system; 2. Halt is the simplest shutdown command, which actually calls the [shutdown -h] command; 3. The function of reboot is Restart; 4. init is the ancestor of all processes, and its process number is always 1.

What is the difference between linux shutdown commands

The operating environment of this article: windows10 system, red hat enterprise linux 6.1, thinkpad t480 computer.

Differences in Linux shutdown commands:

1. The shutdown

shutdown command is used to safely shut down the Linux system. Some users will shut down Linux by directly cutting off the power supply, which is very dangerous. Because Linux is different from Windows in that many processes are running in the background, forced shutdown may cause data loss of processes, 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. You can use the shutdown command to shut down the system directly, delay the shutdown for a specified time, or restart the system. Delaying the system shutdown for a specified period of time allows the user time to save files currently being processed and close open programs.

Some parameters of the shutdown command are as follows:

  • [-t]Specify how long to shut down the system after

  • [-r]Restart the system

  • [-k]It does not actually shut down the system, but only for each logged-in user Send warning signal

  • [-h]Shut down the system (halt)

The essence of the shutdown command is to init The program sends a signal (signal), requiring it to switch the run level (Runlevel) of the system. The running levels of the system include:

  • 0: Shut down the system

  • 1: Single-user mode, if -h or - is not specified for the shutdown command r parameter and execute it directly, 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: Re- Start the system

2, halt

halt is the simplest shutdown command, which actually calls the 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]Forced shutdown or restart without calling shutdown

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

  • [-p]Shut down When poweroff is called, this option is the default option

3, reboot

The working process of reboot is similar to halt, and its function is to restart , and halt means shutdown. Its parameters are also similar to halt.

4. 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 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 linux shutdown commands. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!