https://wiki.archlinux.org/api.php?action=feedcontributions&user=Jhorchler&feedformat=atomArchWiki - User contributions [en]2024-03-29T05:29:09ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Keyboard_shortcuts&diff=465806Keyboard shortcuts2017-01-19T10:56:20Z<p>Jhorchler: Written down the steps to use SysRq on Lenovo Laptops.</p>
<hr />
<div>[[Category:Keyboards]]<br />
[[Category:X server]]<br />
[[Category:Accessibility]]<br />
[[ja:キーボードショートカット]]<br />
[[zh-hans:Keyboard shortcuts]]<br />
This article provides a list of (not commonly known) default keyboard shortcuts and provides information about user customization.<br />
<br />
== Standard shortcuts ==<br />
<br />
=== Kernel ===<br />
<br />
There are several low level shortcuts that are implemented in the kernel 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).<br />
<br />
To use these, they must first be activated with either {{ic|1=sysctl kernel.sysrq=1}} or {{ic|echo "1" > /proc/sys/kernel/sysrq}}. If you wish to have it enabled during boot, edit {{ic|/etc/sysctl.d/99-sysctl.conf}} and insert the text {{ic|1=kernel.sysrq = 1}}. If you want to make sure it will be enabled even before the partitions are mounted and in the initrd, then add {{ic|1=sysrq_always_enabled=1}} to your kernel boot command line options.<br />
<br />
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.<br />
<br />
{| class="wikitable"<br />
! Keyboard Shortcut<br />
! Description<br />
|-<br />
| {{ic|Alt+SysRq+r}} '''Unraw''' <br />
| Take control of keyboard back from X.<br />
|-<br />
| {{ic|Alt+SysRq+e}} '''Terminate''' <br />
| Send SIGTERM to all processes, allowing them to terminate gracefully.<br />
|-<br />
| {{ic|Alt+SysRq+i}} '''Kill''' <br />
| Send SIGKILL to all processes, forcing them to terminate immediately.<br />
|-<br />
| {{ic|Alt+SysRq+s}} '''Sync''' <br />
| Flush data to disk.<br />
|-<br />
| {{ic|Alt+SysRq+u}} '''Unmount''' <br />
| Unmount and remount all filesystems read-only.<br />
|-<br />
| {{ic|Alt+SysRq+b}} '''Reboot'''<br />
| Reboot<br />
|-<br />
|}<br />
<br />
{{Tip|<br />
* If you are using a [[display manager]] and after {{ic|Alt+SysRq+e}} you are presented with the login screen (or full desktop if autologin is enabled), it is most likely caused by {{ic|1=Restart=always}} directive in the relevant [[systemd|service file]]. If necessary, [[systemd#Editing provided units|edit the unit]], however this should not prevent the "REISUB" sequence from working.<br />
* If all the above combinations work except {{ic|Alt+SysRq+b}}, try using the contralateral {{ic|Alt}} key.<br />
* On laptops that use {{ic|Fn}} key to differentiate {{ic|SysRq}} from {{ic|PrtScrn}}, it may not actually be necessary to use the {{ic|Fn}} key (i.e., {{ic|Alt+PrtSc+''letter''}} could work).<br />
* On Lenovo laptops {{ic|SysRq}} is often configured as {{ic|Fn+S}}. To use it press and hold {{ic|Alt}} then press {{ic|Fn+s}}, '''release''' {{ic|Fn}} and {{ic|s}} still holding {{ic|Alt}} followed by the keys above. <br />
* You may need to press {{ic|Ctrl}} along with {{ic|Alt}}. So for example, full key shortcut would be {{ic|Ctrl+Alt+SysRq+b}}.<br />
}}<br />
<br />
See [[wikipedia:Magic SysRq key|Magic SysRq key - Wikipedia]] for more details.<br />
<br />
=== Terminal ===<br />
<br />
==== Virtual console ====<br />
<br />
{| class="wikitable"<br />
! Keyboard Shortcut<br />
! Description<br />
|-<br />
| {{ic|Ctrl+Alt+Del}}<br />
| Reboots Computer (specified by the symlink {{ic|/usr/lib/systemd/system/ctrl-alt-del.target}})<br />
|-<br />
| {{ic|Alt+F1}}, {{ic|F2}}, {{ic|F3}}, ...<br />
| Switch to ''n''-th virtual console<br />
|-<br />
| {{ic|Alt+ &larr;}}<br />
| Switch to previous virtual console<br />
|-<br />
| {{ic|Alt+ &rarr;}}<br />
| Switch to next virtual console<br />
|-<br />
| {{ic|Scroll Lock}}<br />
| When Scroll Lock is activated, input/output is locked<br />
|-<br />
| {{ic|Shift+PgUp}}/{{ic|PgDown}}<br />
| Scrolls console buffer up/down<br />
|-<br />
| {{ic|Ctrl+c}}<br />
| Kills current task<br />
|-<br />
| {{ic|Ctrl+d}}<br />
| Inserts an EOF<br />
|-<br />
| {{ic|Ctrl+z}}<br />
| Pauses current Task<br />
|}<br />
<br />
==== Readline ====<br />
<br />
GNU readline is a commonly used library for line-editing; it is used for example by Bash, FTP, and many more (see the details of {{Pkg|readline}} package under "Required By" for more examples). readline is also customizable (see man page for details).<br />
<br />
{| class="wikitable"<br />
! Keyboard Shortcut<br />
! Description<br />
|-<br />
| {{ic|Ctrl+l}}<br />
| Clear the screen<br />
|- <br />
| colspan=2 align="center" | '''Cursor Movement'''<br />
|-<br />
| {{ic|Ctrl+b}}<br />
| Move cursor one character to the left<br />
|-<br />
| {{ic|Ctrl+f}}<br />
| Move cursor one character to the right<br />
|-<br />
| {{ic|Alt+b}}<br />
| Move cursor one word to the left<br />
|-<br />
| {{ic|Alt+f}}<br />
| Move cursor one word to the right<br />
|-<br />
| {{ic|Ctrl+a}}<br />
| Move cursor to start of the line<br />
|-<br />
| {{ic|Ctrl+e}}<br />
| Move cursor to end of the line<br />
|-<br />
| colspan=2 align="center" | '''Copy & Paste'''<br />
|-<br />
| {{ic|Ctrl+u}}<br />
| Cut everything from line start to cursor<br />
|-<br />
| {{ic|Ctrl+k}}<br />
| Cut everything from the cursor to end of the line<br />
|-<br />
| {{ic|Alt+d}}<br />
| Cut the current word after the cursor<br />
|-<br />
| {{ic|Ctrl+w}}<br />
| Cut the current word before the cursor<br />
|-<br />
| {{ic|Ctrl+y}}<br />
| Paste the previous cut text<br />
|-<br />
| {{ic|Alt+y}}<br />
| Paste the second latest cut text<br />
|-<br />
| {{ic|Alt+Ctrl+y}}<br />
| Paste the first argument of the previous command<br />
|-<br />
| {{ic|Alt+.}}/{{ic|_}}<br />
| Paste the last argument of the previous command<br />
|-<br />
| colspan=2 align="center" | '''History'''<br />
|-<br />
| {{ic|Ctrl+p}}<br />
| Move to the previous line<br />
|-<br />
| {{ic|Ctrl+n}}<br />
| Move to the next line<br />
|-<br />
| {{ic|Ctrl+s}}<br />
| Search<br />
|-<br />
| {{ic|Ctrl+r}}<br />
| Reverse search<br />
|-<br />
| {{ic|Ctrl+j}}<br />
| End search<br />
|-<br />
| {{ic|Ctrl+g}}<br />
| Abort search (restores original line)<br />
|-<br />
| {{ic|Alt+r}}<br />
| Restores all changes made to line<br />
|-<br />
| colspan=2 align="center" | '''Completion'''<br />
|-<br />
| {{ic|Tab}}<br />
| Auto-complete a name<br />
|-<br />
| {{ic|Alt+?}}<br />
| List all possible completions<br />
|-<br />
| {{ic|Alt+*}}<br />
| Insert all possible completions<br />
|-<br />
|}<br />
<br />
=== X11 & Wayland ===<br />
<br />
{| class="wikitable"<br />
! Keyboard Shortcut<br />
! Description<br />
! Notes<br />
|-<br />
| {{ic|Ctrl+Alt+F1}}, {{ic|F2}}, {{ic|F3}}, ...<br />
| Switch to ''n''-th virtual console<br />
| If it does not work, try {{ic|Ctrl+Fn+Alt+F…}}.<br />
|-<br />
| {{ic|Shift+Insert}} <br> {{ic|Mouse Button 2}}<br />
| Paste text from the [[Clipboard|PRIMARY buffer]]<br />
| By default, Qt maps {{ic|Shift+Insert}} to CLIPBOARD instead of the PRIMARY buffer (see e.g. [http://doc.qt.io/qt-5/qlineedit.html#details]) and {{ic|Ctrl+Shift+Insert}} is mapped to the PRIMARY buffer.<br />
|-<br />
|}<br />
<br />
== User customization ==<br />
<br />
=== Readline ===<br />
<br />
{{Merge|Readline|This section duplicates content of the main article.}}<br />
<br />
This example adds keys that allow (in ''vi-mode'') to search backward through the history for the string of characters between the start of the current line and the point. This is a non-incremental search.<br />
{{hc|.inputrc|<br />
set editing-mode vi<br />
set keymap vi-insert<br />
"\C-r": history-search-backward<br />
"\C-e": history-search-forward<br />
}}<br />
<br />
=== X11 ===<br />
<br />
See [[Keyboard configuration in Xorg#Frequently used XKB options]] for some common shortcuts, that are disabled by default.<br />
<br />
=== Firefox ===<br />
<br />
Use the [https://addons.mozilla.org/en-us/firefox/addon/customizable-shortcuts/ customizable-shortcuts] add-on.<br />
<br />
=== Key binding for X-selection-paste ===<br />
<br />
{{Accuracy|1=The shortcuts presented here are mixed up or outdated: {{ic|F12}} in Firefox toggles the developer tools [https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly?redirectlocale=en-US&redirectslug=Keyboard+shortcuts#w_tools] and {{ic|Shift+Insert}} pastes the PRIMARY buffer.}}<br />
<br />
Users who prefer to work rather with the keyboard 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:<br />
#In Firefox, select a string you want to google for (with the mouse).<br />
#Hit {{ic|Ctrl+k}} to enter the "Google search" field.<br />
#Hit {{ic|F12}} to paste the buffer, instead of moving the mouse pointer to the field and center-click to paste.<br />
<br />
{{Note|{{ic|Shift+Insert}} has a similar yet different functionality, see [[#X11]]: {{ic|Shift+Insert}} inserts the clipboard buffer, not the x-selection-paste buffer. In some applications, these two buffers are mirrored.}}<br />
<br />
The method suggested here uses three packages available in the [[official repositories]]:<br />
<br />
* {{Pkg|xsel}} to give access to the x-selection-buffer content.<br />
* [[Xbindkeys]] to bind a key-stroke to an action.<br />
* {{Pkg|xvkbd}} to pass the buffer string to the application by emulating keyboard input.<br />
<br />
This example binds the x-selection-paste operation to the {{ic|F12}} key:<br />
<br />
{{hc|.xbindkeysrc|<br />
"xvkbd -no-jump-pointer -xsendevent -text "\D1`xsel`" 2>/dev/null"<br />
F12<br />
}}<br />
<br />
The {{ic|"\D1"}} code prefixes a 100 ms pause to inserting the selection buffer (see the [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]).<br />
<br />
{{Note|Depending on your X configuration, you may need to drop the {{ic|-xsendevent}} argument to xvkbd.}}<br />
The key codes for keys other than {{ic|F12}} can be determined using {{ic|xbindkeys -k}}.<br />
<br />
'''References:'''<br />
* [http://unix.stackexchange.com/questions/11889/pasting-x-selection-not-clipboard-contents-with-keyboard Pasting X selection (not clipboard) contents with keyboard]<br />
* [http://homepage3.nifty.com/tsato/xvkbd/ xvkbd home page]<br />
<br />
'''XMonad Window Manager'''<br />
<br />
In the {{Pkg|xmonad}} window manager there is a built-in function to paste the x-selection-buffer content. In order to bind that function to a key-stroke (here {{ic|Insert}} key) the following configuration can be used:<br />
{{hc|xmonad.hs|<br />
import XMonad.Util.Paste<br />
...<br />
-- X-selection-paste buffer<br />
, ((0, xK_Insert), pasteSelection) ]<br />
}}<br />
<br />
'''Using xdotool''' - command-line X11 automation tool<br />
<br />
With the {{Pkg|xdotool}} it is possible to create a short cut which actually pastes the content of the X-Selection buffer via triggering the middle mouse button. Instead of hit the text as separate key strokes. The command for the short cut is:<br />
<br />
<code>xdotool getwindowfocus key --window %1 click 2</code><br />
<br />
The command get the window which has focus from the xserver and triggers a click of button 2 which is the middle mouse button.<br />
<br />
== Tips and tricks ==<br />
<br />
* If you like a keyboard-centered workflow, you might also appreciate a [[Window manager#Tiling_window_managers|tiling window manager]].<br />
<br />
== See also ==<br />
* [https://www.kernel.org/doc/Documentation/sysrq.txt The Linux Magic System Request Key - Kernel documentation]<br />
* [http://lnag.sourceforge.net/lnag_html/node5.html Linux Newbie Administrator Guide - Shortcuts and Commands]<br />
* [http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO.html The Linux keyboard and console HOWTO]</div>Jhorchler