Howto: Shut down Linux from the Openbox right-click menu

This is kind of a weird problem with a lot of different solutions. Usually it’s a trick to shut down the computer from the right-click menu in Openbox if you’re using a privileged user account, not a root account. That’s because the right-click menu can’t spawn the password box needed to ask permission to shut down.

There are a couple of ways around that. You could use a third-party program like gksu, which is particularly suited to the task. The unfortunate part of using gksu is that, in Ubuntu, it’s marked as dependent upon a whole scrambled mess of Gnome packages. (Actually, the Arch version is too.) And as you know, I hate Gnome dependencies.

There are less elegant, but also effective, ways of doing this. If the command needs a reply from sudo, spawn it via a terminal. In other words, kick it through the menu like this.

xterm -e sudo halt

Simple enough: Start a terminal and if your password is needed, your next prompt should ask for it. Get it right and the shutdown sequence starts; get it wrong and life goes on.

On the other hand, if you just want to click a button and shut down, then a password isn’t ideal. In that case, this method might be an improvement.

Edit /etc/sudoers (which technically you should do with the visudo command, but I don’t) and add this line at the bottom.

%users ALL=NOPASSWD: /sbin/halt

That allows everyone in the group “users” to issue the halt command without a password.

You should already have something like this in your sudoers file; if not, you might want to add it.


That’s the line that screens for proper sudo access to start with. In other words, if you’re not in the group “wheel”, you shouldn’t be able to run any systemwide command like halt.

Now add the command line to your Openbox menu, either through ObMenu or via direct editing. In either case, the actual command should just be …

sudo halt

Reconfigure Openbox, and that should allow you to shutdown without a password. (I don’t think you need a restart, but you might.) Note that this doesn’t mean you can run sudo without a password at all; other commands should still be screened normally.

It’s worth noting that this method should work for other window managers with editable menus — like JWM and others.


6 thoughts on “Howto: Shut down Linux from the Openbox right-click menu

  1. billy

    Thank you, KMandla. Is there a reason why you use halt instead of ‘shutdown -h now’ (and ‘shutdown -r now’ for reboot)? Is there any real difference?

  2. Sam

    billy, it’s really a matter of personal preference. Also, it depends on the system.

    For some reason, shutdown -h now only takes me to a login console, but poweroff turns off the computer.

    I used the NOPASSWD method.

  3. Patrick

    All, on a minimal Hardy install I was unable to assign permissions as outlined in this article. Hope it helps someone else.

    %users ALL=(ALL) NOPASSWD: /sbin/halt

  4. babouk

    Thank You for the useful little tutorial
    I did not know, how to halt my arch/fluxbox system without
    password …
    Now I put into my menu.
    I use it for halt and for reboot also …


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s