![I want one of my users to be able to 'sudo init 5' without being asked for a passwd. How to do it?](https://linux22.com/image/828270/I%20want%20one%20of%20my%20users%20to%20be%20able%20to%20'sudo%20init%205'%20without%20being%20asked%20for%20a%20passwd.%20How%20to%20do%20it%3F.png)
I want one of my users (let's call him: pn) to be able to start X by sudo init 5
.
I don't want to give him access to any other commands.
I read man sudoers
, but I don't understand too much of it.
Can anyone provide a quick line to add to /etc/sudoers
file that would do the trick?
I would be grateful eternally.
答案1
Run sudo visudo
and add the following line to the end of /etc/sudoers:
pn [hostname] = (root) NOPASSWD: /sbin/init 5
Replace [hostname] with the output of hostname
.
After this change, the user pn will be able to execute sudo init 5
without a password.