如果我的计算机上登录了多个人,则在关闭计算机时,Ubuntu需要超级用户身份验证。我怎样才能让任何用户在不被要求输入密码的情况下关闭计算机?
您不需要解决方法,只需更改策略以允许您关闭而无需作为管理员进行身份验证以关闭并在多个用户登录时重新启动。
使用您喜欢的文本编辑器编辑文件/usr/share/polkit-1/actions/org.freedesktop.consolekit.policy。您将需要root权限。
在其他人登录时更改与关闭相关的部分
<action id="org.freedesktop.consolekit.system.stop-multiple-users">
<description>Stop the system when multiple users are logged in</description>
<message>System policy prevents stopping the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
至
<action id="org.freedesktop.consolekit.system.stop-multiple-users">
<description>Stop the system when multiple users are logged in</description>
<message>System policy prevents stopping the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
和其他人登录时重启的部分
<action id="org.freedesktop.consolekit.system.restart-multiple-users">
<description>Restart the system when multiple users are logged in</description>
<message>System policy prevents restarting the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin_keep</allow_active>
</defaults>
</action>
至
<action id="org.freedesktop.consolekit.system.restart-multiple-users">
<description>Restart the system when multiple users are logged in</description>
<message>System policy prevents restarting the system when other users are logged in</message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
这将允许您在多个用户登录时关闭并重新启动PC。您是否想要这样做是一个不同的问题。
Richard Holloway的答案 实际上并不是PolickKit授权的授权方式。 /usr/share/polkit-1/actions
下安装的文件无意修改。相反,您应该修改/etc/polkit-1/localauthority/50-local.d/
下的权限。
以下是您对此问题的处理方式:
创建一个名为/etc/polkit-1/localauthority/50-local.d/allow_all_users_to_shutdown.pkla
的文件,并使用sudoedit
对其进行编辑,如下所示:
[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.stop-multiple-users
ResultInactive=no
ResultActive=yes
然后在同一目录中创建另一个.pkla
文件。使用以.pkla
结尾的任何名称,例如allow_all_users_to_restart.pkla
,并将其填入以下内容:
[Allow all users to restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.restart-multiple-users
ResultInactive=no
ResultActive=yes
有一个更好的办法。如果安装了dbus-send,则可以通过dbus关闭无需升级到root权限。
我不记得文档所在的页面,但是一个Archlinux用户想出了这个。
关机:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Shutdown
重新启动:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot
挂起:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1
休眠:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
问候。
HAL似乎现在已经拆除,并且没有安装在最新的Ubuntu版本中。
您必须使用 ConsoleKit 和 Power dbus服务来管理电源状态
关掉:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
重新开始:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
暂停:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
休眠:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
感谢Arch Linux 论坛 。
这在Precise和Quantal中现在有效,但是不知道Freedesktop焦点似乎从ConsoleKit转移到systemd多久了。不知道Canonical是否关心......
这适用于14.04。以前的更新变体,IMO,正确 由Flimm回答 。
Sudo mkdir -p /etc/polkit-1/localauthority/50-local.d
sudoedit /etc/polkit-1/localauthority/50-local.d/allow_all_users_to_shutdown_reboot_suspend.pkla
粘贴在里面:
[Allow all users to shutdown]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off-multiple-sessions
ResultActive=yes
[Allow all users to reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot-multiple-sessions
ResultActive=yes
[Allow all users to suspend]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-multiple-sessions
ResultActive=yes
[Allow all users to ignore inhibit of shutdown]
Identity=unix-user:*
Action=org.freedesktop.login1.power-off-ignore-inhibit
ResultActive=yes
[Allow all users to ignore inhibit of reboot]
Identity=unix-user:*
Action=org.freedesktop.login1.reboot-ignore-inhibit
ResultActive=yes
[Allow all users to ignore inhibit of suspend]
Identity=unix-user:*
Action=org.freedesktop.login1.suspend-ignore-inhibit
ResultActive=yes
在重新启动时,没有办法规避超级用户密码的提示,而在打开终端窗口并以root身份发出reboot
命令的情况下记录其他用户:
Sudo reboot
即便如此,如果未配置为绕过用户帐户的密码提示,Sudo
也会提示您输入密码。
别担心,这些都是好东西。重新启动应该是罕见的,一个简单的管理员密码提示保存意外冲洗自己!
添加暂停和/或重新启动到分配给您希望允许执行此任务的组/用户的sudoers文件。这样你仍然可以控制谁可以关闭,但没有给他们完全root权限访问机器..
http://linux.byexamples.com/archives/315/how-to-shutdown-and-reboot-without-Sudo-password/
我相信这只是通过命令行进行的一个问题。
如果是这样的话 链接 可以帮助您解决问题。