ubuntu server 关机命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu server 关机命令相关的知识,希望对你有一定的参考价值。

参考技术A ubuntu server 关机命令,以下命令都能实现关机。
shutdown
poweroff

linux系统怎么关机?

直接按开机的电源键。
linux下,按 电源键会产生关机消息,接收消息的脚本会调用关机命令关机,与手动输入关机命令,或者使用鼠标点击菜单,对话框关机的过程是完全一样的。
我在win7,winxp下也是,很方便,它们都和菜单,对话框的关机效果一样。
我使用的是ubuntu12.04 server版,系统中电源键关机脚本是
其它linux发行版也差不多,都有自己的处理脚本
/etc/acpi/powerbtn.sh
#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

[ -r /usr/share/acpi-support/power-funcs ] && . /usr/share/acpi-support/power-funcs

# getXuser gets the X user belonging to the display in $displaynum.
# If you want the foreground X user, use getXconsole!
getXuser()
user=`pinky -fw | awk \' if ($2 == ":\'$displaynum\'" || $(NF) == ":\'$displaynum\'" ) print $1; exit; \'`
if [ x"$user" = x"" ]; then
startx=`pgrep -n startx`
if [ x"$startx" != x"" ]; then
user=`ps -o user --no-headers $startx`
fi
fi
if [ x"$user" != x"" ]; then
userhome=`getent passwd $user | cut -d: -f6`
export XAUTHORITY=$userhome/.Xauthority
else
export XAUTHORITY=""
fi
export XUSER=$user


# Skip if we just in the middle of resuming.
test -f /var/lock/acpisleep && exit 0

# If the current X console user is running a power management daemon that
# handles suspend/resume requests, let them handle policy This is effectively
# the same as \'acpi-support\'s \'/usr/share/acpi-support/policy-funcs\' file.

[ -r /usr/share/acpi-support/power-funcs ] && getXconsole
PMS="gnome-settings-daemon kpowersave xfce4-power-manager"
PMS="$PMS guidance-power-manager.py dalston-power-applet"

if pidof x $PMS > /dev/null; then
exit
elif test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x /usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; then
exit
elif test "$XUSER" != "" && test -x /usr/bin/qdbus; then
kded4pid=$(pgrep -n -u $XUSER kded4)
if test "$kded4pid" != ""; then
dbusaddr=$(su - $XUSER -c "grep -z DBUS_SESSION_BUS_ADDRESS /proc/$kded4pid/environ")
if test "$dbusaddr" != "" && su - $XUSER -c "export $dbusaddr; qdbus org.kde.kded" | grep -q powerdevil; then
exit
fi
fi
fi

# If all else failed, just initiate a plain shutdown.
/sbin/shutdown -h now "Power button pressed"

所谓的不能直接按电源键关机的说法,是15年前的老电脑,
它们的关机键,就是一个简单的电源开关,与拔电源的效果是一样的,
瞬间断电,
对于现在的电源管理方式,没有权威的人提出这个,没有必要,成为一种固定模式了,
教材也一直沿用以前的说法
参考技术A ...poweroff 关闭电源 shutdown -h now 现在关机
shutdown: invalid option -- -
Usage: shutdown [-akrhfnc] [-t secs] time [warning message]
-a: use /etc/shutdown.allow
-k: don't really shutdown, only warn.
-r: reboot after shutdown.
-h: halt after shutdown.
-f: do a 'fast' reboot (skip fsck).
-F: Force fsck on reboot.
-n: do not go through "init" but go down real fast.
-c: cancel a running shutdown.
-t secs: delay between warning and kill signal.
** the "time" argument is mandatory! (try "now") **
参考技术B 右键--终端,然后切换到ROOT权限。才可以使用shutdown 命令、我一般都是直接shutdown now
然后就立即关机了。
参考技术C 终端 shutdown 参考技术D 终端命令输入:init 0 第5个回答  2012-05-28 在桌面空白处右键单击 选择新建终端 输入 init0 回车

以上是关于ubuntu server 关机命令的主要内容,如果未能解决你的问题,请参考以下文章

linux系统怎么关机?

ubuntu系统怎么关机

ubuntu怎么关机

ubuntu关机命令是啥?

ubuntu16.04怎么用命令行关机重启

Linux关机和重启命令及区别