命令行大全

halt

喵喵 发表于 2020-07-16 16:37浏览次数:

在类似Unix的操作系统上,停止、断电和重新启动命令分别停止、关闭或重新启动系统。

本文档介绍了GNU/linux版本的“停止”、“断电”和“重新引导”。

This document covers the GNU/Linux versions of halt, poweroff, and reboot.

查看英文版

目录:

1 halt 运行系统环境

2 halt 描述

3 halt 语法

4 halt 技术描述

5 halt 选择

6 halt 环境

7 halt 文件

8 halt 示例

halt 运行系统环境

Unix&Linux

halt 描述

“关闭”、“断电”和“重新引导”是您可以作为根用户运行以停止系统硬件的命令。
  • 关闭指示硬件停止所有CPU功能。
  • 电源关闭发送一个ACPI信号来指示系统断电。
  • 重新启动指示系统重新启动。
这些命令需要超级用户特权。如果您不是以root身份登录,则需要在命令前面加上sudo,否则就不会发送信号。
halt, poweroff, and reboot are commands you can run as root to stop the system hardware.
  • halt instructs the hardware to stop all CPU functions.
  • poweroff sends an ACPI signal which instructs the system to power down.
  • reboot instructs the system to reboot.
These commands require superuser privileges. If you are not logged in as root, you will need to prefix the command with sudo or the signal will not be sent.

查看英文版

查看中文版

halt 语法

reboot [OPTION]... [REBOOTCOMMAND]
halt [OPTION]...
poweroff [OPTION]...
reboot [OPTION]... [REBOOTCOMMAND]
halt [OPTION]...
poweroff [OPTION]...

查看英文版

查看中文版

halt 技术描述

这些程序允许系统管理员重新启动、停止或关闭系统。
当调用-force或在运行级别0或6中时,该工具调用重新启动系统调用自身(传递REBOOTCOMMAND参数)并直接重新启动系统。否则,这将使用适当的参数调用关机工具,而不传递REBOOTCOMMAND参数。

在调用重新启动之前,首先将关机时间记录写入

/var/log/wtmp

These programs allow a system administrator to reboot, halt or poweroff the system.
When called with --force or when in runlevel 0 or 6, this tool invokes the reboot system call itself (with REBOOTCOMMAND argument passed) and directly reboots the system. Otherwise, this invokes the shutdown tool with the appropriate arguments without passing REBOOTCOMMAND argument.

Before invoking reboot, a shutdown time record is first written to

/var/log/wtmp

查看英文版

查看中文版

halt 选择

-f--force 不调用关机,而是执行您希望从名称中得到的实际操作。
-p--poweroff 指示“停止”命令代之以“断电”。
-w--wtmp-only 不调用关机或重新启动系统调用,而是只将关闭记录写入/var/log/wtmp。
--verbose 重新启动时输出更详细的消息,这对于调试关机问题很有用。
-f--force Does not invoke shutdown and instead performs the actual action you would expect from the name.
-p--poweroff Instructs the halt command to instead behave as poweroff.
-w--wtmp-only Does not call shutdown or the reboot system call and instead only writes the shutdown record to /var/log/wtmp.
--verbose Outputs slightly more verbose messages when rebooting, which can be useful for debugging problems with shutdown.

查看英文版

查看中文版

halt 环境

RUNLEVEL 如果首选地设置为/var/run/utmp,则重新引导将从此环境变量读取当前运行级。
RUNLEVEL reboot will read the current runlevel from this environment variable if set in preference to reading from /var/run/utmp.

查看英文版

查看中文版

halt 文件

/var/run/utmp 从其中读取当前运行级的文件;该文件还将被更新,运行级记录将被关闭时间记录替换。
/var/log/wtmp 关闭时间的新运行级记录将附加到此文件中。
/var/run/utmp File where the current runlevel will be read from; this file will also be updated with the runlevel record being replaced by a shutdown time record.
/var/log/wtmp A new runlevel record for the shutdown time will be appended to this file.

查看英文版

查看中文版

halt 示例

halt
如果您是以root身份登录的,发出HART命令将停止系统上的所有CPU功能。在大多数系统上,这将使您进入单用户模式,然后关闭计算机。
sudo halt

如果您没有以root用户身份登录,则需要在halt命令前面加上sudo,以超级用户的身份运行该命令。

poweroff

如果您以root身份登录,发出poweroff命令将发送ACPI硬件信号,该信号将指示系统在完全和立即关闭时开始。这大致相当于在典型的桌面计算机上按下电源按钮。

sudo poweroff

以root用户身份执行poweroff命令。

reboot

如果您以root身份登录,发出reboot命令将立即启动一个重新启动序列。系统将关闭,然后开始一个温暖的启动。

sudo reboot
以root用户身份执行reboot命令。
halt
If you are logged in as root, issuing the halt command will cease all CPU function on the system. On most systems, this will drop you into single-user mode and then power off the machine.
sudo halt

If you are not logged in as root, you will need to prefix the halt command with sudo to run the command as the superuser.

poweroff

If you are logged in as root, issuing the poweroff command will send an ACPI hardware signal which will instruct the system to commence with a complete and immediate shutdown. This is roughly equivalent to pressing the power button on a typical desktop computer.

sudo poweroff

Execute the poweroff command as root.

reboot

If you are logged in as root, issuing the reboot command will immediately initiate a reboot sequence. The system will shut down and then commence a warm boot.

sudo reboot
Execute the reboot command as root.

查看英文版

查看中文版