Redian新闻
>
Let a non-root user turn off computer
avatar
Let a non-root user turn off computer# Linux - Linux 操作系统
B*s
1
In Ubuntu Server, I can "sudo shutdown -h now" to turn off computer if I am
logged in as a root.
Now I need to do it in a non-root account. I don't want this account to have
root privilege, for security concern. But this account should be able to
turn off computer.
What should I do?
Last year I heard of one function, that root can generate one shell file
using root privilege, and give permission to non-root to run the shell
command with temporary root-privilege. But I forget what that function
avatar
e*n
2
这个,
在一般的desktop上不都是non-root可以关机么?

am
have

【在 B*********s 的大作中提到】
: In Ubuntu Server, I can "sudo shutdown -h now" to turn off computer if I am
: logged in as a root.
: Now I need to do it in a non-root account. I don't want this account to have
: root privilege, for security concern. But this account should be able to
: turn off computer.
: What should I do?
: Last year I heard of one function, that root can generate one shell file
: using root privilege, and give permission to non-root to run the shell
: command with temporary root-privilege. But I forget what that function

avatar
Z*0
3
可以在sudo里边加允许普通用户shutdown,no password。
自己看sudo.conf
avatar
B*s
4
Thanks, Zer0. visudo and added one line:
user hostname = NOPASSWD: /sbin/shutdown
now the user(non-root) can sudo shutdown , but can't sudo anything else.
That is exactly what I want.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。