First, the run-level definition of init
1,# init 0 system starts the rc0 script kills the running process, shuts down the operating system. Use the virtual machine test to shut down to the " shutdown " state;
2,# init 1 system kills the running process after booting into single user mode. With virtual machine testing you can see that the virtual machine is initialized to single-user mode and the remote user is out. Press ctrl+d(exit) to restart thedevice and restore to multi-user status;
3,# init 5 The system shuts down the operating system after it kills the running process. Using a virtual machine test, "however there is nothing Luan to use ", no shutdown operating system appears;
4,# intit 6 reboot .
ii.shutdown,poweroff,reboot order
1,shutdown used more commands in the shutdown action. The Shutdown is mainly completed by the following processes to complete the shutdown.
1, specify the shutdown time, and send a message to the user in use;
2, then run Init 0 to kill all processes;
3, run sync to synchronize the in-memory data to the hard disk;
4, the last call halt into the shutdown mode;
2,shutdown common Operation
1, through ---help view shutdown Common parameters
[[Email protected] ~]# shutdown --helpusage: shutdown [option]... time [message]bring the system down. options: -r rebootafter shutdown -h haltor power off after shutdown -H halt after shutdown (implies-h) -P poweroff after shutdown (implies -h) -c cancela running shutdown -k onlysend warnings, don ' T shutdown -q,--quiet reduce output to errors only
2, example 1:
Window 1:[[email protected] ~]# shutdown 23:30 #直接加时间指明某刻关机. Broadcast message from [e-mail protected] (/DEV/PTS/2) at 22:56 ... The system is going down for maintenance in34 minutes! #如果想取消也可以按Ctrl +c cancel Shutdown:shutdown cancelled # #在另外一个终端使用-C parameter canceled
Window 2:[[email protected] ~] #Broadcast message from [e-mail protected] (/DEV/PTS/2) at 22:56 ... The system is going down for maintenance in34 minutes! #窗口1命令引起的消息 [[email protected] ~]# shutdown–c #在另外一个终端使用-C Cancel
3, example 2:
[Email protected] ~]# Shutdown # The system is going down for maintenance in30 minutes! [Email protected] ~]# Shutdown-r now # The system was going down for reboot now!
3,halt command
The halt command only completes part of the shutdown process, he does not notify the logged-on user, does not perform a kill operation, and immediately shutdown, if #halt is used –q Will immediately stop the system, no synchronization, no kill process or write logs, very dangerous.
[Email protected] ~]# haltbroadcast message from [e-mail protected] (/dev/pts/0) at 23:13 ... The system is going down for halt now!
4,poweroff command
The Poweroff command does not notify the logged-on user, does not perform a Kill script operation, immediately shutdown and power down. Commonly used in conjunction with the Sync command such as:#sync; reboot.
Third, Summary:halt,poweroff,reboot are more dangerous operations, generally do not recommend the use of these commands. Or you need to use "Sync" sync before using these commands .
When using shutdown, You can use the # shutdown now–k only to send a shutdown message and not to actually shut down the computer.
This article is from the "Ding classmate 1990" blog, please be sure to keep this source http://dingtongxue1990.blog.51cto.com/4959501/1687856
Linux Shutdown related commands