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.


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.