Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have desktop edition of Ubuntu.

I like the Terminal so that that I prefer to shutdown my computer with the shutdown command.

However when I type shutdown now it prompts me to enter my password.Is there any way I can shutdown my computer using this command without entering my password?

share|improve this question
Does anyone know what command is executed when I click "shutdown" in Desktop Environment? –  kubahaha Feb 20 at 17:15

3 Answers 3

Run visudo and add one of the following line:

%group_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown


user_name ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown

This allows the user/group to run the above three commands, using sudo, however with no password.

So, sudo poweroff will now result in a passwordless shutdown.

However, to make this even cleaner, we'll add an alias, so that running shutdown calls sudo shutdown now.

Open ~/.bash_aliases for editing.

nano ~/.bash_aliases

Insert the following line at the end of the file:

alias shutdown='sudo shutdown now' 

Finally, load the changes to the .bash_aliases file...

source ~/.bash_aliases

Try it out!


Thanks, Eric.

share|improve this answer
You could in addition create an alias. Put the following at the end of ~/.bashrc: alias shutdown='sudo shutdown now' this way you just have to type shutdown to shutdown the computer. –  Eric Carvalho Jul 27 '12 at 15:31
Good point. Edited. –  SirCharlo Jul 27 '12 at 15:33
@EricCarvalho I have no problem typing the command, but password. –  Santosh Kumar Jul 27 '12 at 15:44
@SirCharlo Even I added that line to the visudo. It is still asking for password. –  Santosh Kumar Jul 31 '12 at 2:14
I had to use the full path for it to not require the password: sudo /sbin/reboot –  Mike McKay Jan 6 '13 at 2:42

A safe way to do this without using sudo and without tinkering with the system, is by executing this one-liner command:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

consolekit Install consolekit should of course be installed your system.

Original source: https://bbs.archlinux.org/viewtopic.php?id=127962

share|improve this answer
This solution should be the closest equivalent to use the command from the top right menu, isn't it? –  gerlos Feb 20 at 16:57
@gerlos It seems that it is in fact the command passed by the DE to the system. Anyone can confirm this? –  Majal Mar 3 at 9:02

You can run the following command:

sudo chmod u+s /sbin/shutdown

This means that whenever any user calls shutdown, it will be run as the file owner(in this case root). This is obviously dangerous, so don't use it on other files.

This will allow you to use shutdown without sudo at all. To make sure that you are the only user who can do this, and thus ensure better security, run the following command instead of, or after, the above:

sudo chown root:your_user_name /sbin/shutdown && sudo chmod 4770 /sbin/shutdown

This is similar to the above, but will also restrict use of shutdown to the primary group of your user account.

A final warning: don't do this to any other files than shutdown, and make sure to get it right. Granting unauthorized people root acces on you system will severely compromise security.

share|improve this answer
-1 because of the danger of setting things setuid and messing with permissions in /sbin - there are better ways to do this securely. –  ImaginaryRobots Jul 27 '12 at 16:26
Correct me if I'm wrong, but if done correctly this should allow only the user specified to access the shutdown command, and block all others. If used on other files, it could be really bad. I've added a better warning to the answer now. –  Kalle Elmér Jul 27 '12 at 22:45

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.