How to turn off the computer in linux
The editor will share with you how to turn off the computer in linux. I hope you will gain a lot after reading this article. Let's discuss it together.
There are several commands to choose from in Linux. Let's take a look at some of the older commands.
Shutdown
The shutdown command shuts down the system safely. Shutdown performs its job is to send a signal to the init program, asking it to change the runlevel. Runlevel 0 is used to halt and runlevel 6 is used to reactivate the system.
For example:
Shutdown command: shutdown-h now
Restart command: shutdown-r now
Halt
Halt shutting down immediately is equivalent to shutdown-h now, but halt is actually calling shutdown-h. When halt executes, it kills the application process, executes the sync system call, and stops the kernel after the file system write operation is complete. But this only stops the operating system, and the power supply is still working.
Poweroff
Poweroff shuts down the system and then sends a power-off signal to acpi.
Init
Init is the ancestor of all processes, and its process number is always 1, so sending TERM signals to init terminates all user processes, daemons, and so on.
Init is a command to switch the execution level. There are seven levels of execution in Linux, and the more important are the following four levels:
Run level 0: shutdown
Run level 3: command line mode only
Run level 5: with graphical interface mode
Run level 6: restart
Reboot
Reboot works in much the same way as halt. However, it causes the host to restart, while halt shuts down.
Now
Now the new distribution uses systemd, and these commands are softly connected to systemctl or systemd, which means that now the shutdown and power management are all taken over by systemd, so these commands are all the same.
Systemctl [instruction]
Halt enters the system stop mode, and the screen may retain some messages, which is related to your power management mode.
Poweroff enters the system shutdown mode, direct shutdown does not provide power!
Reboot restarts directly
Suspend enters hibernation mode
After reading this article, I believe you have a certain understanding of how to turn off the computer in linux. You want to know more about it. Welcome to follow the industry information channel. Thank you for your reading!