What are the script commands for server restart under Linux?

Source: Internet
Author: User

Linux shutdown and restart systems are generally implemented using the same commands.
In Linux systems, the shutdown/Restart commands are commonly used in shutdown, halt, reboot, and INIT, but the internal working process of each command is different.

1. Shutdown command
The shutdown command can safely shut down the system, and some users will use a direct power-down source to turn off the computer, which is very dangerous.
Unlike Windows, Linux runs many processes in the background, so forcing a shutdown can cause data loss to the process, leave the system in an unstable state, and even damage hardware devices in some systems.
If you use the Shutdown command before the system shuts down, the system administrator notifies all logged-on users that the system is about to close, and the login command is frozen, that is, the new user can no longer log on. It is possible to shut down directly or delay a certain amount of time before shutting down, and it may be possible to restart the computer.
Syntax: shutdown [options] [TIME] [warning message]
Option Description:
-K: Not really shut down, just send a warning message to all users
-R: Restart immediately after shutdown
-H: Do not restart after shutdown
-F: Fast shutdown, skip fsck when restarting
-N: Fast shutdown without init program
-C: Cancel an already running Shutdown[-time]: Set the time before shutdown
Example:
1) immediately shut down the system: shutdown-h now
2) shut down the system after 45min timer: Shutdown-h 45
3) Reboot the system and issue a warning message: Shutdown–r Now "system would be reboot now!"
2. Halt command
The halt command is executed by invoking the "shutdown-h" command.
Syntax: halt [Options]
Option Description:
-C: Prevents sync system calls, which is used after fsck patched the root partition to prevent the kernel from overwriting the patched super block with the old version of the Super Block
-W: not a real restart or shutdown, just write Wtmp (yunjinquan.com) record
-D: Do not write wtmp record (included in option [-n])
-F: Force shutdown or restart without calling shutdown
-I: Turn off all network interfaces before shutting down (or restarting)
-P: This option is the default option, which is to call Poweroff when shutting down
3. Reboot command
The working process of reboot is similar to that of halt, but the reboot is to trigger the host reboot, and Halt is to trigger the main machine. Its parameters are similar to halt
4. Init command
Init is the ancestor of all processes, and its process number is always 1, so sending a trem signal to init terminates all user processes and daemons.
Shutdown is the use of this mechanism. Init defines 7 RunLevel, where init0 is shutdown and init restarts.

What are the script commands for server restart under Linux?

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.