Linux初学笔记之开机关机命令

关机命令有三个halt,shutdown,poweroff,以及重启命令reboot
1、halt确有其命令,以及man内容。
2、shutdown也是专门负责关机的命令,并是独立的程序。
3、poweroff命令并不存在,但他直接调用的是halt -p的默认命令参数,是link过来的,下面我也提到了
4、reboot是重启命令,作用内容可以参考halt的man
......
1、[root@acnis root]# halt --help
usage: halt [-n] [-w] [-d] [-f] [-i] [-p]
-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.
-p: power down the system (if possible, otherwise halt)
参数说明:
[-n] 防止 sync 系统调用,它用在用fsck修补根分区之后,以阻止内核用老版本的超级块(superblock)覆盖修补过的超级块。
[-w] 并不是真正的重启或关机,只是写 wtmp(/var/log/wtmp)纪录。
[-d] 不写 wtmp 纪录(已包含在选项 [-n] 中)。
[-f] 没有调用 shutdown 而强制关机或"重启"(指的是reboot)。
[-i] 关机(或重启)前,关掉所有的网络接口。
[-p] 该选项为缺省选项。就是关机时调用 poweroff。 (isher喜欢直接用poweroff命令)
[-h] 在系统关闭之前,从系统中正确的移除所有的磁盘驱动器。

2、说明poweroff命令很多人不知道,这也是在/sbin下面的命令,是一个link,连接到halt -p的命令上。

[root@acnis sbin]# ll |grep pow
lrwxrwxrwx 1 root root 4 2002-01-13 poweroff -> halt

为了说明,MAN一下poweroff
MAN poweroff(halt) 得到以下内容,可以作为对照,对于halt -h
同时包含了halt命令和reboot的解释,因为poweroff本就是halt的快捷方式而已(windows的话)
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]
OPTIONS
-n Don't sync before reboot or halt.
-w Don't actually reboot or halt but only write the wtmp record (in
the /var/log/wtmp file).
-d Don't write the wtmp record. The -n flag implies -d.
-f Force halt or reboot, don't 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.

[root@acnis root]# shutdown --help
shutdown: invalid option -- -
Usage: shutdown [-akrhfnc] [-t secs] time [warning message]
-a: use /etc/shutdown.allow
-k: don't really shutdown, only warn.
-r: reboot after shutdown.
-h: halt after shutdown.
-f: do a 'fast' reboot (skip fsck).
-F: Force fsck on reboot.
-n: do not go through "init" but go down real fast.
-c: cancel a running shutdown.
-t secs: delay between warning and kill signal.
** the "time" argument is mandatory! (try "now") **
参数说明
shutdown 命令可以安全地关闭或重启Linux系统,它在系统关闭之前给系统上的所有登录用户提示一条警告信息。该命令还允许用户指定一个时间参数,可以是一个精确 的时间,也可以是从现在开始的一个时间段。精确时间的格式是hh:mm,表示小时和分钟;时间段由“ ”和分钟数表示。系统执行该命令后,会自动进行数据同步的工作。
该命令的一般格式为: shutdown [选项] [时间] [警告信息] 命令中各选项的含义为:
[-t] seconds : 设定在几秒钟之后进行关机程序
[-k] 并不真正关机,而只是发出警告信息给所有用户。
[-r] 关机后立即重新启动。
[-h] 关机后不重新启动。
[-f] 快速关机,重启动时跳过fsck。
[-F] : 关机时,强迫进行 fsck 动作
[-n] 快速关机,不经过init程序。
[-c] 取消一个已经运行的shutdown。
×需要特别说明的是,该命令只能由超级用户使用。
time : 设定关机的时间
message : 传送给所有使用者的警告讯息
MAN shutdown 得到以下内容,可以作为对照
NAME
shutdown - bring the system down
SYNOPSIS
/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message]
OPTIONS
-a Use /etc/shutdown.allow.
-t sec Tell init(8) to wait sec seconds between sending processes the
warning and the kill signal, before changing to another run-
level.
-k Don't really shutdown; only send the warning messages to every-
body.
-r Reboot after shutdown.
-h Halt after shutdown.
-n [DEPRECATED] Don't call init(8) to do the shutdown but do it
ourself. The use of this option is discouraged, and its results
are not always what you'd expect.
-f Skip fsck on reboot.
-F Force fsck on reboot.
-c Cancel an already running shutdown. With this option it is of
course not possible to give the time argument, but you can enter
a explanatory message on the command line that will be sent to
all users.

 

你可能感兴趣的:(linux,重启,关机)