Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
It worked, thanks. – Vlad K. Dec 5 '12 at 21:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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