Isa*_*iah 51 administration shutdown
如果超过一个人登录我的电脑,Ubuntu在关闭电脑时需要超级用户身份验证。我怎样才能让任何用户都可以在不要求输入密码的情况下关闭计算机?
Fli*_*imm 37
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
Run Code Online (Sandbox Code Playgroud)
然后.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
Run Code Online (Sandbox Code Playgroud)
Ric*_*way 29
您不需要解决方法,只需更改策略以允许您在多个用户登录时无需以管理员身份进行关机和重启即可关机。
使用您喜欢的文本编辑器编辑文件 /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>
Run Code Online (Sandbox Code Playgroud)
到
<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>
Run Code Online (Sandbox Code Playgroud)
以及与其他人登录时重新启动有关的部分
<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>
Run Code Online (Sandbox Code Playgroud)
到
<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>
Run Code Online (Sandbox Code Playgroud)
这将允许您在多个用户登录时关闭并重新启动 PC。是否要这样做是一个不同的问题。
ibu*_*law 16
有个更好的方法。如果您安装了 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
Run Code Online (Sandbox Code Playgroud)
重启:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Reboot
Run Code Online (Sandbox Code Playgroud)
暂停:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:1
Run Code Online (Sandbox Code Playgroud)
休眠:
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
/org/freedesktop/Hal/devices/computer \
org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
Run Code Online (Sandbox Code Playgroud)
问候。
Epe*_*eli 12
HAL 现在似乎已弃用,并且未安装在最新的 Ubuntu 版本中。
您必须使用ConsoleKit和UPower dbus 服务来管理电源状态
关掉:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
Run Code Online (Sandbox Code Playgroud)
重新开始:
dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
Run Code Online (Sandbox Code Playgroud)
暂停:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Run Code Online (Sandbox Code Playgroud)
休眠:
dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate
Run Code Online (Sandbox Code Playgroud)
感谢 Arch Linux论坛。
这现在在 Precise 和 Quantal 中有效,但不知道 Freedesktop 的重点似乎从 ConsoleKit 转移到 systemd 多久了。不知道 Canonical 是否在乎...
这适用于 14.04。Flimm之前的 IMO 正确答案的更新变体。
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
Run Code Online (Sandbox Code Playgroud)
把这个贴在里面:
[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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
60084 次 |
最近记录: |