Linux command learning summary: explain the reboot command in detail
- 2020-05-13 04:23:17
- OfStack
Command summary:
This command is used to restart the Linux system. Equivalent to the restart command in the Windows system.
Command syntax:
/sbin/reboot [-n] [-w] [-d] [-f] [-i]
or
reboot [-n] [-w] [-d] [-f] [-i]
Command parameters:
参数 |
长参数 |
描叙 |
-d |
重新启动时不把数据写入记录文件/var/tmp/wtmp |
|
-f |
强制重新开机,不调用shutdown指令的功能。 |
|
-h |
在系统关机或poweroff之前,将所有的硬盘处于待机模式 |
|
-i |
关闭网络设置之后再重新启动系统 |
|
-n |
保存数据后再重新启动系统 |
|
-p |
When halting the system, do a poweroff. This is the default when halt is called as poweroff |
|
-w |
仅做测试,并不真的将系统重新开机,只会把重开机的数据写入/var/log目录下的wtmp记录文件 |
|
--help |
显示命令在线帮助 |
Use examples:
1: view the help information for the reboot command
[root@DB-Server ~]# reboot --help
usage: reboot [-n] [-w] [-d] [-f] [-h] [-i]
-n: don't sync before halting the system
-w: only write a wtmp reboot record and exit.
-d: don't write a wtmp record.
-f: force halt/reboot, don't call shutdown.
-h: put harddisks in standby mode.
-i: shut down all network interfaces.
[root@DB-Server ~]# man reboot
[root@DB-Server ~]# man reboot
HALT(8) Linux System Administrator � � Manual HALT(8)
NAME
halt, reboot, poweroff - stop the system.
SYNOPSIS
/sbin/halt [-n] [-w] [-d] [-f] [-i] [-p] [-h]
/sbin/reboot [-n] [-w] [-d] [-f] [-i]
/sbin/poweroff [-n] [-w] [-d] [-f] [-i] [-h]
DESCRIPTION
Halt notes that the system is being brought down in the file /var/log/wtmp, and then either tells the kernel to halt, reboot or poweroff the system.
If halt or reboot is called when the system is not in runlevel 0 or 6, in other words when it � � running normally, shutdown will be invoked instead (with
the -h or -r flag). For more info see the shutdown(8) manpage.
The rest of this manpage describes the behaviour in runlevels 0 and 6, that is when the systems shutdown scripts are being run.
OPTIONS
-n Don � � sync before reboot or halt. Note that the kernel and storage drivers may still sync.
-w Don � � actually reboot or halt but only write the wtmp record (in the /var/log/wtmp file).
-d Don � � write the wtmp record. The -n flag implies -d.
-f Force halt or reboot, don � � call shutdown(8).
-i Shut down all network interfaces just before halt or reboot.
-h Put all harddrives on the system in standby mode just before halt or poweroff.
-p When halting the system, do a poweroff. This is the default when halt is called as poweroff.
DIAGNOSTICS
If you � � e not the superuser, you will get the message � � ust be superuser � ? Users logged in locally on the console can call halt, reboot, and poweroff
without supplying the root password, due to pam_console (8).
NOTES
Under older sysvinit releases , reboot and halt should never be called directly. From release 2.74 on halt and reboot invoke shutdown(8) if the system is
not in runlevel 0 or 6. This means that if halt or reboot cannot find out the current runlevel (for example, when /var/run/utmp hasn � � been initialized
correctly) shutdown will be called, which might not be what you want. Use the -f flag if you want to do a hard halt or reboot.
The -h flag puts all harddisks in standby mode just before halt or poweroff. Right now this is only implemented for IDE drives. A side effect of putting
the drive in standby mode is that the write cache on the disk is flushed. This is important for IDE drives, since the kernel doesn � � flush the write-cache
itself before poweroff.
The halt program uses /proc/ide/hd* to find all IDE disk devices, which means that /proc needs to be mounted when halt or poweroff is called or the -h
switch will do nothing.
AUTHOR
Miquel van Smoorenburg, miquels@cistron.nl
SEE ALSO
shutdown(8), init(8), pam_console(8)
Nov 6, 2001 HALT(8)
(END)
2: force reboot without calling the function of shutdown instruction
[root@DB-Server ~]# reboot -f
3: turn off network Settings and restart the system
[root@DB-Server ~]# reboot -i
Broadcast message from root (pts/1) (Mon Jul 28 11:31:28 2014):
The system is going down for reboot NOW!
4: save the data and restart the system
[root@DB-Server ~]# reboot -n
Broadcast message from root (pts/1) (Mon Jul 28 11:33:57 2014):
The system is going down for reboot NOW!
5: the data is not written to the record file /var/tmp/wtmp when restarted
[root@DB-Server ~]# reboot -d
Broadcast message from root (pts/2) (Mon Jul 28 11:23:26 2014):
The system is going down for reboot NOW!