
我最近安裝了 Openbox,並閱讀了一份指南,其中指出應透過以下命令關閉 PC:
gdm-control --shutdown && openbox --exit
然而,這似乎有點違反直覺。為什麼我要先關閉電腦然後退出 Openbox?這怎麼可能?
或者可能gdm-control --shutdown
只是在某個地方發送訊息?如果電腦在 Openbox 退出之前關閉怎麼辦?這真的是「正確的方法」嗎?
資訊:
Openbox 指南連結:http://urukrama.wordpress.com/openbox-guide/
作業系統:Debian Linux 7.0
答案1
像這樣建立一個別名。然後只需輸入shut
.
alias shut="su -c 'shutdown -h now'"
您需要是 root 才能執行此操作,這就是為什麼您首先將使用者設定為超級使用者 ( su
),然後發出命令 ( -c
)。用於-h
關閉後“停止”,即不要重新啟動(或執行任何其他操作)。
答案2
我參加聚會有點晚了,但為了回答這怎麼可能的問題,gdm-control 的手冊頁說明了一切:
DESCRIPTION
gdm-control lets you control gdm from within an X session. It enables
you to change GDM's behaviour for when you end the current sesson. For
instance, you can tell GDM to reboot, and then immediately log out of
the current session, and the computer will be rebooted
OPTIONS
...<snip>...
--shutdown
Shutdown the computer when the current session ends.
因此,您告訴 gdm 在會話結束時關閉,然後結束會話。
對我自己來說,我嘗試了什麼在這個問題中建議並發現這systemctl poweroff
對我來說效果很好。