A Keyboard Shortcut for the 'shutdown' Command, and Modifying the sudoers File

How to make a keyboard shortcut for shutdownLove keyboard shortcuts.By default, Dapper is shut down by clicking an icon on the desktop. So, a mouse is necessary. In addition, you go through an extra step, as a dialogue box pops up in response.

As for the configuration of any other user-defined keyboard shortcut, launch the editor from the terminal (or with a keyboard shortcut...):gconf-editor

In the GUI:apps>metacity>keybinding_commands: gksudo haltThen, in the global_keybindings tab : [favourite_shortcut]

As explained by Cucisan, gksudo is required by the graphic environment. It means the same as sudo in the terminal.Mind you don't use something already taken by the system. CTRL-s, for example, is set to 'save as'...

Getting rid of the password popup (making 'shutdown' available to an ordinary user, not su)To bypass the need to put in a password, followed the following instructions by Vivek.

The need to provide a password stems from the requirement to have superuser privileges in order to carry out some commands.One of those commands is 'halt'.Allowing use of such restricted commands by ordinary users requires modifying the sudoers file. This is a dangerous tweak. Was really careless in handling this myself, and spent a while with my heart in my mouth.

Warning: modifying sudoers is dangerous, should only be done when necessary and after proper study of the topic.

visudoOnly the visudo command allows access to the 'sudoers' file.Study man visudo.It will help to know what to do if you get into real trouble with visudo, as I have. Please see Sweet Recovery Mode and its Uses.

Before you start, you need to know the absolute path to your command. This can be obtained by:

which

To open 'sudoers' (/etc/sudoers):

$ sudo visudo.

Do not open the file directly, or do anything else directly with it.It is to be edited only with visudo.

Inside sudoersAt the bottom of the file or at the 'user privilege spefication', append:

your_user_name ALL= NOPASSWD: /sbin/halt

It is desirable, as usual to preced this with some comment:

#Allwing ordinary users to use 'halt' without a password.

Now, save. You will be asked to confirm saving to /etc/sudoers.tmp, not /etc/sudoers.You should say 'y'. The .tmp file is only a temporary version to allow one final hurdle before modifying 'sudoers' for good. The visudo command will now parse the changes for any syntax errors.

If there are any, visudo will issue an error message and ask 'what now?'.To this, only two answers should really be considered: 'e' (back to editing) or 'x' (exit without saving the changes).

In my hands, the above (NOPASSWD) line only accepts one user and one command at a time. Proceeding otherwise will not be picked up by the visudo parser, yet will not dispense the user from the password prompt.

If all's well, you'll get the prompt again.

And, you'll be able to shut down the computer from the keyboard, without being prompted for a password.Not bad.