关闭的正确终端方式是什么?

Ric*_*uez 44 command-line shutdown

我试图通过 SSH 关闭我的电脑。我执行了

sudo shutdown now

用户已注销并且 Ubuntu 开始关闭,但它在带有 Ubuntu 徽标和加载点的最后一个屏幕上冻结。知道问题出在哪里吗?

此外,有什么之间的区别shutdownhalt?还有哪些类似的命令?

Lui*_*ado 41

从手册页:

关机- “关机安排以安全的方式关闭系统。所有登录用户都会收到系统正在关闭的通知,并且在 TIME 的最后五分钟内,将阻止新的登录。” 这里提到的时间是用户指定的关闭时间。

暂停- “这些程序允许系统管理员重新启动、暂停或关闭系统。”

不同之处在于,在关闭时 Halt 可能比 Shutdown 本身更“激进”。它的参数可以从字面上强制系统关闭而不考虑服务或打开的程序。如果你不带任何参数运行halt,它只会执行shutdown 命令。类似于别名的东西。例如,如果您使用参数运行它,--force它将“强制”系统非常快速地重新启动。

在停止或关机的情况下,他们将等待所有进程正确完成,然后再关闭或重新启动 PC。如果服务或应用程序未关闭或未正确关闭,您将看到您在那里提到的内容(带有点的 ubuntu 徽标)。

终端中单用户或多用户的正确方式是关机。但是,如果关闭不起作用,请验证您正在运行哪些服务以及哪个服务导致关闭缓慢或冻结。

考虑到这一点,有几种方法可以重新启动或关闭系统:

重新启动- shutdown -rreboot

在这种情况下,reboot 只是调用shutdown -r.

关机- halt, shutdown, sudo init 0, shutdown -h now,poweroff

在这种情况下,poweroff与调用相同shutdown -P

正如您所注意到的,该shutdown命令可以做很多事情,这里是它的一个小列表:

-r  Requests that the system be rebooted after it has been brought down
-h  Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system
-H  Requests that the system be halted after it has been brought down
-P  Requests that the system be powered off after it has been brought down
-c  Cancels a running shutdown. TIME is not specified with this option, the first argument is MESSAGE
-k  Only send out the warning messages and disable logins, do not actually bring the system down
Run Code Online (Sandbox Code Playgroud)

就像 reboot

-f, --force                 force reboot or halt, don't call shutdown(8)
-p, --poweroff              switch off the power when called as halt
Run Code Online (Sandbox Code Playgroud)

然而,通过终端关闭和单击 Unity 中的关闭选项是有区别的。后者将要求用户与任何未保存的作品(如 libreoffice、inkscape...)进行交互。前者只会向所有进程发送一个信号,告诉它们关闭。不需要用户交互,因此任何未保存的工作都将消失。

  • @RiMMER `shutdown` 关闭操作系统,但实际上并没有关闭计算机。您需要一个额外的参数,例如`shutdown -P`,或者改为调用`poweroff`。(它们是相同的。)类似命令的完整列表是`reboot`、`halt`、`poweroff` 和`shutdown`。 (17认同)
  • 那么在使用顶部栏中的关闭按钮执行此操作时,Ubuntu 是如何正确关闭的呢?这与终端命令有什么不同?为什么这有效而终端命令无效?这很奇怪...... (2认同)

小智 8

您需要做的是通过运行以下命令在计算机关闭后关闭电源:

须藤关机 -P 20