In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you what are the linux shutdown commands. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Linux shutdown command
The commonly used shutdown commands under linux are: shutdown, halt, poweroff, init; restart commands: reboot. The following article mainly introduces some commonly used shutdown commands as well as the differences and specific uses between various shutdown commands.
First of all, let's take a look at some commonly used shutdown commands under linux.
Shutdown command:
1. Halt shuts down immediately 2, poweroff shuts down immediately 3, shutdown-h now shuts down immediately (used by root users) 4, shutdown-h 10 10 minutes later automatic shutdown if the shutdown is set by the shutdown command, you can use the shutdown-c command to cancel the restart
Restart command:
1. Reboot 2, shutdown-r now immediately restart (for root users) 3, shutdown-r 10 automatically restart after 10 minutes (for root users) 4, shutdown-r 20:35 restart at 20:35 (for root users) if the restart is set by the shutdown command, you can cancel the restart with the shutdown-c command
Let's take a look at the differences between these specific shutdown commands of linux and their respective uses.
1.shutdown secure shutdown command
For the shutdown command, it is a recommended safe command that completes shutdown or restart through the combination of the parameter-h or-r. However, on linux systems, you can only use this command if you have root privileges. So, although everyone recommends this command, it is really inconvenient to use: do you want to use this command? Let's get root access first. When shutdown performs a shutdown, it sends a signal to init to change its running level to shut down. Shutdown or restart is actually a run-level adjustment, so we can also use init to adjust the run-level directly for shutdown or restart. When you use this command, the machine shuts down or restarts immediately. It also requires root permissions.
So why is it that the shutdown command shuts down the system safely?
In practice, some users will turn off linux by directly cutting off the power supply, which is very dangerous. Because linux is different from windows in that there are many processes running in the background, forced shutdown may result in data loss of the process and leave the system in an unstable state. Even in some systems, the hardware will be damaged. Using the shutdown command before the system shuts down, the system administrator will inform all logged-in users that the system is going to shut down. And the login instruction is frozen, meaning that new users can no longer log in. It is possible to shut down the phone directly or delay it for a certain amount of time, or it is possible to restart it. This is determined by the fact that all processes (process) receive a signal (signal) delivered by the system.
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, runlevel 6 is used to reactivate the system, and runlevel 1 is used to put the system into a state where administrative work can be done. Suppose there is no-h and no-r parameter to shutdown. Want to know what actions were taken during halt or reboot? You can see these runlevels-related materials in this file / etc/inittab.
Shutdown parameter description:
[- t] before changing to another runlevel, tell init how long it will take to shut down.
[- r] restart the calculator.
[- k] doesn't really turn it off, it just sends a warning signal to each login.
[- h] turn off the power supply (halt) after shutdown.
[- n] turn off the phone yourself instead of init. The use of this option is discouraged, and the consequences of this option are not always what you expect.
[- c] cancel current process cancels the currently executing shutdown program. So of course there is no time parameter for this option, but you can enter a message for interpretation, and this information will be sent to each user.
[- f] ignore fsck when restarting the calculator (reboot).
[- F] forces fsck when restarting the calculator (reboot).
[- time] sets the time before shutdown (shutdown).
The simplest shutdown command for 2.halt
When you shut down the machine with the halt command, you actually call shutdown-h. When halt executes, it kills the application process, and when the sync system call file system write operation is completed, the kernel is stopped.
Halt parameter description:
[- n] prevents sync system calls, which are used after patching the root partition with fsck to prevent the kernel from overwriting the patched super block with an older version of the superblock.
[- w] is not really rebooting or shutting down, just writing wtmp (/ var/log/wtmp) records.
[- d] do not write wtmp records (already included in the option [- n]).
[- f] forced shutdown or restart without calling shutdown.
[- I] turn off all network interfaces before shutting down (or restarting).
[- p] this option is the default. It is to call poweroff when the computer is turned off.
Shutdown commands commonly used in 3.poweroff
For poweroff, it is said on the Internet that it is a link to the halt command, and its basic usage is similar to that of halt, so I won't say much here.
4.init
Init is the ancestor of all processes, and he is one of the indispensable programs in Linux system operation. Its process number is always 1, so sending a TERM signal to init will terminate all user processes, daemons, etc. Shutdown uses this mechanism. Init defines eight runlevels (runlevel), with init 0 as shutdown and init 1 as restart.
5.reboot restart command
Reboot works in much the same way as halt. However, it causes the host to restart, while halt shuts down. Its parameters are not much different from those of halt.
These are the linux shutdown commands that Xiaobian shared with you. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.