Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Is it possible to create a keyboard shortcut that will run:

shutdown -h now

When I press Ctrl + 9, for example.

share|improve this question
Any particular OS? – Ignacio Vazquez-Abrams Nov 6 '11 at 2:49
Debian sid, running XFCE. I would prefer to have the shortcut run regardless of whether or not X / XFCE has been started though (I sometimes use the machine as a server). Which is why I thought inittab might work. – Mike Nov 6 '11 at 2:53
Bear in mind that bindings listed in inittab can be overridden by your WM/DE/OS. If you want it to be truly global, you will need to also configure your environment to allow it to act as so. – Chris Down Nov 6 '11 at 12:31
up vote 2 down vote accepted

You can define two such shortcuts on the Linux console. Pressing Ctrl+Alt+Del sends the SIGINT signal to init; this triggers the ctrlaltdel action in inittab. This action usually triggers /sbin/shutdown -t1 -a -r now (reboot now); change that to /sbin/shutdown -t1 -a -h now if you want to halt instead. The other shortcut is the KeyboardSignal console key (bound to Alt+Up by default, but you can change that in your console keymap), which triggers the kbrequest action in inittab.

Note that these bindings may not be triggered while you're in X. Under X, you can use your window manager's key binding features, or another program such as xbindkeys. Note that under X, you don't get a free pass to run commands as root; if you want to trigger a reboot without entering a password, you'll need a NOPASSWD entry in sudoers.

(Aside: Ctrl+9 looks awfully easy to type by mistake. It's also a keyboard shortcut in several applications. Pick something rarer and with two modifiers!)

share|improve this answer

Something pretty similar does probably already work: see SysRq key sequences (see also the Linux kernel documentation). Some variant of REISUB, maybe REISUO (O for poweroff instead of B for reboot) could be what you want.
Not as quick and versatile as a way of binding Ctrl+9 to any command, but a possibility.

share|improve this answer
This is neat, up-voted you for it. – Mike Nov 6 '11 at 21:57

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.