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

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

sudo shutdown now

用户已注销,Ubuntu开始关闭,但它在最后一个屏幕上冻结了Ubuntu徽标和加载点。 知道问题可能在哪里?

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

来自MAN PAGES:

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

暂停 – “这些程序允许系统管理员重启,暂停或关闭系统电源。”

不同之处在于Halt在关闭时比关闭本身更具“攻击性”。 它具有的参数可以在没有关于服务或打开的程序的情况下强制关闭系统。 如果在没有任何参数的情况下运行暂停,它将只执行shutdown命令。 像别名一样的东西。 如果您使用参数--force运行它,它将“强制”系统重新启动非常快。

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

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

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

重启shutdown -rreboot

在这种情况下,重启只是调用shutdown -r

关闭haltshutdownsudo init 0shutdown -h nowpoweroff

在这种情况下, 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 

reboot

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

但是,通过终端关闭和单击Unity中的关闭选项之间存在差异。 后者将要求用户与任何未保存的工作(如libreoffice,inkscape …)进行交互。 前者只会向所有进程发送信号,告诉他们关闭。 不需要用户交互,因此任何未保存的工作都将消失。

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

sudo shutdown -P 20

关闭系统的另一个命令是

sudo init 0

init 0调用所有关闭脚本并正常关闭您的计算机。