Linux switch command details

  
 For the daily use of the Linux system, it is necessary to use the command line to carry out, for example, the ordinary switch machine is no exception, and the Linux system switch machine mainly involves (shutdown, reboot, poweroff, halt, init) Commands, the use of these commands and the power on/off process are described in detail below.

1. Command Introduction
shutdown, poweroff, reboot, halt, init can be shut down, roughly usage.
/sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]/sbin/reboot [-n] [-w] [-d ] [-f] [-i]/sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h][root@linux ~]$ reboot --h
usage: reboot [-n] [-w] [-d] [-f] [-h] [-i]-n: Not synchronized before stopping the system
-w: Write only wtmp reboot record and leave < Br>-d: Do not write wtmp records
-f: Force shutdown or restart
-h: Put the hard disk in stand-alone mode
-i: Close all network interfaces
Second, shutdown process
1. Refresh the hard disk cache:
2. Record the restart event: (/var/run/utmp, /var/log/wtmp)
3. Kill all processes:
4. Finally restart the machine:
Three, shutdown example
# shutdown -h now # Immediate shutdown
# shutdown -h 2:30 'halt' #2点30 minutes shutdown, pay attention to the local time
# halt -p # Immediate shutdown
# init 0 # Immediately switch the system running level to 0, ie shutdown
# shutdown now #Switch to single-player mode (without any options)
4. Restart example
# shutdown -k now 'reboot' #Warning message, but not really shutting down.
# shutdown -t5 -r now #Restart now, but in warning and delete Between 5 seconds.
# init 6 # Immediately switch the system run level to 6, ie reboot
# shutdown -r +10 'reboot' #10分钟 Restart
# shutdown -c # cancel the previous shutdown command
# shutdown -r now #immediately restart
five, shutdown preparation
Linux is no more than Windows
, if you can not shut down properly, because it is too late to write data back to the file, It may cause file system corruption. So pay attention before shutting down:
1. Observe the system status
Use the who command to view the online user
Use the netstat -a command to view the network connection status
Use the ps aux command to view the background execution program.
2. Notify online users #shutdown -k now 'System will reboot in 30 minutes!'
3. Use the correct command # first to find out whether it is shutdown or restart, and then pay attention to the parameters
4. Data Synchronization #Sync data to disk using sync data
6. Other instructions
1. View restart record
# last reboot
2. Remote boot machine
# ssh root@server /sbin /reboot
# ssh [email protected] /sbin/shutdown -r now

Copyright © Windows knowledge All Rights Reserved