shutdown 中文man页面

系统
shutdown 以一种安全的方式关闭系统。所有登陆用户都可以看到关机信息提示,并且 login(1) 将被阻塞。可以指定立刻关机,也可以指定系统在一定的延时后关机。所有进程都将接收到 SIGTERM 信号。

NAME

shutdown - 关闭系统  

总览 SYNOPSIS

/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message]  

描述 DESCRIPTION

shutdown 以一种安全的方式关闭系统。所有登陆用户都可以看到关机信息提示,并且 login(1) 将被阻塞。可以指定立刻关机,也可以指定系统在一定的延时后关机。所有进程都将接收到 SIGTERM 信号。这可以使 vi(1) 等程序有时间将处于编辑状态的文件进行存储,邮件和新闻程序进程则可以将所有缓冲池内的数据进行适当的清除等等。 shutdown 通过通知 init 进程,要求它改换运行级别来实现。运行级别 0 用来关闭系统,运行级别 6 用来重启系统,运行级别 1 用来使系统进入执行系统管理任务状态,如果没有给出 -h-r 标志时,这是 shutdown 命令的默认工作状态。具体关机或重启所执行的操作请查阅 /etc/inittab 文件中相应的运行级别栏。  

选项 OPTIONS

-a
使用 /etc/shutdown.allow 来验证身份。
-t sec
通知 init(8) 在转换到其它运行级别前,发送警告 (warning) 信号后延时 (sec) 秒数后再发送关闭 (kill) 信号。
-k
并非真正关机,只向所有人显示警告信息。
-r
重启。
-h
停机。
-n
[DEPRECATED(不应再使用)] 不调用 init(8) 程序进行关机操作,而由自己进行。不建议用户使用这种关机方式,它的结果一般也不是你希望的那样。
-f
重启时跳过磁盘检测。
-F
重启时强制磁盘检测。
-c
取消运行中的 shutdown 进程。不可能为此选项指定 time 参数,但你可以在命令行输入一条解释消息来向所有用户说明。(一般的shutdown指令可以用按“+”号来进行中断)
time
关机时间。
warning-message
发送给所有用户的消息。


 time 参数的格式可以有很多种。首先,可以是 hh:mm 格式的绝对时间,其中 hh 指的是小时(一到二位数),mm 指的是分钟(二位数)。第二种是 +m 格式,其中 m 指的是等待的分钟数。 now 是 +0 的别名。

如果 shutdown 在调用时使用了延时,它将自动创建一个咨询 (advisory) 文件 /etc/nologin ,作用是禁止 login(1) 允许新用户登陆,除非 shutdown 在向 init 发信号前意外中止 (就是说,它被取消或出了什么问题)。它会在调用 init 改变运行级之前删除这个文件。

-f 标志意味着 `快速重启'。这将创建一个咨询 (advisory) 文件 /fastboot ,此文件在系统重启时会被检测到。启动脚本 rc 会检测是否存在这样的文件,如果有,就不会再运行 fsck(1),因为系统是以正常方式关闭的。这之后,启动进程会删除 /fastboot

-F 标志意味着 `强制 fsck'。这将创建一个咨询 (advisory) 文件 /forcefsck,此文件在系统重启时会被检测到。启动脚本 rc 会检测是否存在这个文件,如果有,就运行 fsck(1) 并且加上一个特殊的 `force' 标志,以使得即使正常卸载的文件系统也被检查。这之后,启动进程会删除 /forcefsck


 -n 标志导致 shutdown 不调用 init 程序进行关机,而是自己关闭所有运行中的进程。shutdown 接下来会关闭配额 (quota),记账 (accounting) 和交换分区,卸载所有文件系统。  

访问控制 ACCESS CONTROL

如果在 /etc/inittab 文件中有适当的条目,当按下特殊键 CTRL-ALT-DEL 时,shutdown 可以被 init(8) 调用。这意味着可以物理地接触到终端键盘的任何人都可以关闭系统。要避免这种行为,shutdown 可以检测是否有授权的用户登录到了虚拟终端之一。如果 shutdown 在调用时带有 -a 参数 (可以将它添加到 /etc/inittab 中 shutdown 的执行命令之后),它将检测是否存在 /etc/shutdown.allow 文件。接下来它比较文件中的登录名与虚拟终端的登录用户列表 (在/var/run/utmp)。只有当授权的用户之一 或者 root 登录了,它才会继续。否则,它会把信息

shutdown: no authorized users logged in

写到 (物理的) 系统终端。/etc/shutdown.allow 的格式是每行一个用户名。允许出现空行和注释行 (以 # 开头)。此文件当前有最多 32 个用户的限制。

注意,如果 /etc/shutdown.allow 不存在,-a 参数将被忽略。  

文件 FILES

/fastboot
/etc/inittab
/etc/init.d/halt
/etc/init.d/reboot
/etc/shutdown.allow

注意 NOTES

很多用户忘记了传递 time 参数,结果被 shutdown 产生的错误消息所迷惑。time 参数是必须的,90% 的情况下这个参数会是 now

Init 只能在终端模式捕获 CTRL-ALT-DEL 并且启动 shutdown。如果系统正在运行 X window System,X 服务器处理所有的按键。一些 X11 环境使得捕获 CTRL-ALT-DEL 成为可能,但是这个事件究竟做了什么依赖于那个环境。

Shutdown 没有被设计为使用 setuid。/etc/shutdown.allow 不用来找出谁在执行 shutdown ,它*只*用来检查当前在终端 (之一) 登录的用户。  

作者 AUTHOR

Miquel van Smoorenburg, miquels@cistron.nl  

参见 SEE ALSO

fsck(8), init(8), halt(8), poweroff(8), reboot(8)  

#p#

NAME

shutdown - bring the system down  

SYNOPSIS

/sbin/shutdown [-t sec] [-arkhncfF] time [warning-message]  

DESCRIPTION

shutdown brings the system down in a secure way. All logged-in users are notified that the system is going down, and login(1) is blocked. It is possible to shut the system down immediately or after a specified delay. All processes are first notified that the system is going down by the signal SIGTERM. This gives programs like vi(1) the time to save the file being edited, mail and news processing programs a chance to exit cleanly, etc. shutdown does its job by signalling the init process, asking it to change the runlevel. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to put to system into a state where administrative tasks can be performed; this is the default if neither the -h or -r flag is given to shutdown. To see which actions are taken on halt or reboot see the appropriate entries for these runlevels in the file /etc/inittab.  

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 runlevel.
-k
Don't really shutdown; only send the warning messages to everybody.
-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.
time
When to shutdown.
warning-message
Message to send to all users.

The time argument can have different formats. First, it can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits). Second, it can be in the format +m, in which m is the number of minutes to wait. The word now is an alias for +0.

If shutdown is called with a delay, it creates the advisory file /etc/nologin which causes programs such as login(1) to not allow new user logins. Shutdown removes this file if it is stopped before it can signal init (i.e. it is cancelled or something goes wrong). It also removes it before calling init to change the runlevel.

The -f flag means `reboot fast'. This only creates an advisory file /fastboot which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide not to run fsck(1) since the system has been shut down in the proper way. After that, the boot process should remove /fastboot.

The -F flag means `force fsck'. This only creates an advisory file /forcefsck which can be tested by the system when it comes up again. The boot rc file can test if this file is present, and decide to run fsck(1) with a special `force' flag so that even properly unmounted filesystems get checked. After that, the boot process should remove /forcefsck.

The -n flag causes shutdown not to call init, but to kill all running processes itself. shutdown will then turn off quota, accounting, and swapping and unmount all filesystems.  

ACCESS CONTROL

shutdown can be called from init(8) when the magic keys CTRL-ALT-DEL are pressed, by creating an appropriate entry in /etc/inittab. This means that everyone who has physical access to the console keyboard can shut the system down. To prevent this, shutdown can check to see if an authorized user is logged in on one of the virtual consoles. If shutdown is called with the -a argument (add this to the invocation of shutdown in /etc/inittab), it checks to see if the file /etc/shutdown.allow is present. It then compares the login names in that file with the list of people that are logged in on a virtual console (from /var/run/utmp). Only if one of those authorized users or root is logged in, it will proceed. Otherwise it will write the message

shutdown: no authorized users logged in

to the (physical) system console. The format of /etc/shutdown.allow is one user name per line. Empty lines and comment lines (prefixed by a #) are allowed. Currently there is a limit of 32 users in this file.

Note that if /etc/shutdown.allow is not present, the -a argument is ignored.  

FILES

/fastboot
/etc/inittab
/etc/init.d/halt
/etc/init.d/reboot
/etc/shutdown.allow

NOTES

A lot of users forget to give the time argument and are then puzzled by the error message shutdown produces. The time argument is mandatory; in 90 percent of all cases this argument will be the word now.

Init can only capture CTRL-ALT-DEL and start shutdown in console mode. If the system is running the X window System, the X server processes all key strokes. Some X11 environments make it possible to capture CTRL-ALT-DEL, but what exactly is done with that event depends on that environment.

Shutdown wasn't designed to be run setuid. /etc/shutdown.allow is not used to find out who is executing shutdown, it ONLY checks who is currently logged in on (one of the) console(s).  

AUTHOR

Miquel van Smoorenburg, miquels@cistron.nl  

SEE ALSO

fsck(8), init(8), halt(8), poweroff(8), reboot(8)

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:33:18

exit中文man

2011-08-24 17:19:00

raw中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-23 17:24:11

userdel中文man

2011-08-23 17:33:22

rdev中文man

2011-08-23 18:05:21

ABORT中文man

2011-08-18 19:15:25

group中文man

2011-08-23 10:17:54

bdflush中文man
点赞
收藏

51CTO技术栈公众号