Keyboard shortcuts

Related articles
Fluxbox#Keyboard shortcuts
i3#Keyboard shortcuts
Linux console#Keyboard shortcuts
LXDE#Keyboard shortcuts
Openbox#Keyboard shortcuts
Xfce#Keyboard shortcuts
Xmonad#X-Selection-Paste
Zsh#Key bindings
This article provides a list of (not commonly known) default keyboard shortcuts and provides information about user customization.
Tip
If you like a keyboard-centered workflow, you might also appreciate a
tiling window manager
.
Standard shortcuts
Kernel (SysRq)
There are several low level shortcuts that are implemented in the kernel via the
SysRq
key which can be used for debugging and recovering from an unresponsive system. Whenever possible, it is recommended that you use these shortcuts instead of doing a hard shutdown (holding down the power button to completely power off the system).
See
Wikipedia:Magic SysRq key
for more details.
Enabling
systemd
has the SysRq permissions bitmask
set to 0x10 by default
, which
does not allow process signalling or rebooting
, among other things. To allow full use of the
SysRq
key on your system, add
kernel.sysrq = 1
to your
sysctl configuration
. Values greater than 1 can be used to selectively enable SysRq functions; see the
Linux kernel documentation
for details. If you want to make sure it will be enabled even before the partitions are mounted and in the initramfs, then add
sysrq_always_enabled=1
to your
kernel parameters
.
Note that changing the setting through these methods will cause the changes to persist across reboots. If you want to try changing the SysRq settings for just your current session, you can run either
sysctl kernel.sysrq=1
or
echo "1" > /proc/sys/kernel/sysrq
.
To avoid security risks involved in fully enabling the
SysRq
function, users may turn on a subset of features, as described in the following section. If unrestricted use of
SysRq
is enabled, it allows killing processes and forcing reboots, which does not increase risk to desktop and laptop users. But it also can be used to dump the contents of the CPU registers, which could theoretically reveal sensitive information. Unless you
go out of your way
, that requires physical access to the system.
Rebooting
A common idiom to remember this is "
R
eboot
E
ven
I
f
S
ystem
U
tterly
B
roken" (also referred to as "REISUB"). Alternatively, think of it as "BUSIER"  backwards.
Note
Please be aware that "REISUB" itself is just a mnemonic, not any kind of general recommendation for the key press sequence to take back control of an unresponsive system. You should not blindly press these sequences each time without knowing their actual function as noted below.
Keyboard Shortcut
Description
Code to Enable
Other Functions Enabled
Alt+SysRq+r
Unraw
Switch keyboard mode for the current virtual console from the
raw
mode to ASCII mode (also known as XLATE mode)
[1]
.
4
Alt+SysRq+k
SAK
Alt+SysRq+e
Terminate
Send SIGTERM to all processes, allowing them to terminate gracefully.
64
Alt+SysRq+f
OOM kill
Alt+SysRq+j
Thaw
Alt+SysRq+i
Kill
Send SIGKILL to all processes, forcing them to terminate immediately.
Alt+SysRq+s
Sync
Flush data to disk.
16
–
Alt+SysRq+u
Unmount
Unmount and remount all filesystems read-only.
32
–
Alt+SysRq+b
Reboot
Reboot
128
–
For example, to selectively enable just the reboot function, set
kernel.sysrq
to 128. The whole set of REISUB functions can be enabled by setting it to 244, although this also enables the additional functions, such as those listed in the last column of the table. For further documentation, see the
SysRq key documentation
and the kernel source file
/drivers/tty/sysrq.c
.
If you have an unresponsive system and want to perform the entire REISUB sequence, do the following:
Press and hold
Alt
.
Press and release
SysRq
(or
Print/PrtScn
if your keyboard doesn't have
SysRq
).
Press and release each of the letters in the mnemonic in order, waiting about 1 second in between each press.
Your system should safely reboot.
Killing a memory-hogging process
Alt+SysRq+f
can be used to invoke the
OOM (out-of-memory) killer
without causing a kernel panic if nothing can be killed. The OOM killer uses a set of heuristics to pick whichever relatively non-vital process is using the most memory and kill it. This is very useful to kill a process that is softlocking your system by causing excessive thrashing, such as a runaway browser script, and can alleviate the need for a reboot in many cases. Note that the OOM killer can target a wide variety of processes despite its well-meaning heuristics and can be somewhat unpredictable, so be careful about calling it casually.
Remote usage
sysrqd
AUR
is a daemon for remotely using
SysRq
functionality. It appears to be currently unmaintained.
[2]
Troubleshooting
If a SysRq action produces output, it is sent to the kernel ring buffer where the
systemd journal
will pick it up. When nothing prevents the output to be displayed on the
Linux console
, it will be there too. Not having a response on the console does not prove the SysRq command was not processed successfully. If that is the case, run
journalctl -kf
to monitor the output as it arrives to the kernel ring buffer.
If you are using a
display manager
and after
Alt+SysRq+e
you are presented with the login screen (or full desktop if autologin is enabled), it is most likely caused by
Restart=always
directive in the relevant
service file
. If necessary,
edit the unit
, however this should not prevent the "REISUB" sequence from working.
If all the above combinations work except
Alt+SysRq+b
, try using the opposite
Alt
key.
On laptops that use
Fn
key to differentiate
SysRq
from
PrintScreen
, it may not actually be necessary to use the
Fn
key (i.e.,
Alt+PrintScreen+
letter
could work).
On Lenovo laptops (outside of their Legion lineup)
SysRq
is often configured as
Fn+S
. To use it press and hold
Alt
then press
Fn+s
,
release
Fn
and
s
still holding
Alt
followed by the keys above.
You may need to press
Ctrl
along with
Alt
, or
AltGr
[3]
. The full key shortcut would be
Ctrl+Alt+SysRq+b
or
AltGr+SysRq+b
.
Some keyboards, like Logitech K835, use
Fn+Ins
to produce
SysRq
.
Xorg and Wayland
Keyboard Shortcut
Description
Notes
Ctrl+Alt+F1
,
F2
,
F3
, ...
Switch to
n
-th virtual console
If it does not work, try
Ctrl+Alt+Fn+F…
.
Shift+Insert
Mouse Button 2
Paste text from the
PRIMARY buffer
By default, Qt maps
Shift+Insert
to CLIPBOARD instead of the PRIMARY buffer (see e.g.
[4]
) and
Ctrl+Shift+Insert
is mapped to the PRIMARY buffer.
Customization
The below tools bind keys to higher-level actions. For tools that only bind keys to other keys, see
Input remap utilities
.
Readline
Readline
is a commonly used library for line-editing; it is used for example by
Bash
, FTP, and many more (see the details of
readline
package under "Required By" for more examples). It has
Emacs
-like and
vi
-like editing modes which can be customized with escape sequences. Default key bindings are listed in
readline(3)
and the
Info documentation
.
Xorg
See
Xorg/Keyboard configuration#Frequently used XKB options
for some common shortcuts, that are disabled by default.
When we are in a graphical environment we may want to execute a command when certain key combination is pressed (i.e. bind a command to a
keysym
). There are multiple ways to do that:
The most portable way using low level tools, such as
acpid
. Not all keys are supported, but configuration in uniform way is possible for keyboard keys, power adapter connection and even headphone jack (un)plugging events. It is also difficult to run programs inside X session correctly.
The universal way using
Xorg
utilities (e.g.
xbindkeys
) and eventually your desktop environment or window manager tools.
The quicker way using a third-party program to do everything in GUI, such as the Gnome Control Center.
sxhkd
A simple X hotkey daemon with a powerful and compact configuration syntax. See
sxhkd
for details.
actkbd
From
actkbd home page
:
actkbd
AUR
is a simple daemon that binds actions to keyboard events. It recognises key combinations and can handle press, repeat and release events. Currently it only supports the linux-2.6 evdev interface. It uses a plain-text configuration file which contains all the bindings.
A sample configuration and guide is available
here
.
xbindkeys
xbindkeys
allows advanced mapping of keysyms to actions independently of the Desktop Environment.
Tip
If you find
xbindkeys
difficult to use, try the graphical manager
xbindkeys_config-gtk2
AUR
.
Key binding for X-selection-paste
The factual accuracy of this article or section is disputed.
Reason:
Shift+Insert
pastes the PRIMARY buffer. (Discuss in
Talk:Keyboard shortcuts
)
This article or section needs expansion.
Reason:
Why the 100ms delay? (Discuss in
Talk:Keyboard shortcuts
)
Users who prefer to work with the keyboard rather than the mouse may benefit from a key binding to the paste operation of the middle mouse button. This is especially useful in a keyboard-centered environment. A workflow example is:
In Firefox, select a string you want to web-search for (with the mouse).
Hit
Ctrl+k
to enter the "search engine" field.
Hit
F9
to paste the buffer, instead of moving the mouse pointer to the field and middle-click to paste.
Note
Shift+Insert
has a similar yet different functionality, see
#Xorg
:
Shift+Insert
inserts the clipboard buffer, not the x-selection-paste buffer. In some applications, these two buffers are mirrored.
The method suggested here uses the following three packages::
xsel
to give access to the x-selection-buffer content.
Xbindkeys
to bind a key-stroke to an action.
xvkbd
AUR
to pass the buffer string to the application by emulating keyboard input.
This example binds the x-selection-paste operation to the
F9
key:
.xbindkeysrc
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"
    F9
The
"\D1"
code prefixes a 100 ms pause to inserting the selection buffer (see the
xvkbd home page
).
Note
Depending on your X configuration, you may need to drop the
-xsendevent
argument to xvkbd.
The key codes for keys other than
F9
can be determined using
xbindkeys -k
.
References:
Pasting X selection (not clipboard) contents with keyboard
xvkbd home page
See also
Linux Newbie Administrator Guide - Shortcuts and Commands
The Linux keyboard and console HOWTO