Handy Keyboard Shortcuts for Linux
The examples in this document assume that you are using a POSIX-compliant (such as bash, sh, zsh, ksh)shell.
Large portions of GNU/Linux functionality are achieved using the terminal. Most distributions of Linux include terminal emulators that allow users to interact with a shell from their desktop environment. A shell is a command- line interpreter that executes user inputted commands. Bash (Bourne Again SHell) is a common default shell among many Linux distributions and is the default shell for macOS.
These shortcuts will work if you are using Bash with the emacs keybindings (set by default):
Cursor Movement Command Line Shortcuts
Ctrl + AGo to the beginning of the line you are currently typing on.
Ctrl + EGo to the end of the line you are currently typing on.
Ctrl + XXMove between the beginning of the line and the current position of the cursor.
Alt + FMove cursor forward one word on the current line.
Alt + BMove cursor backward one word on the current line.
Ctrl + FMove cursor forward one character on the current line.
Ctrl + BMove cursor backward one character on the current line.
Text Manipulation Command Line Shortcuts
Ctrl + UCut the line from the current position to the beginning of the line, adding it to the clipboard. If you are at the end of the line, cut the entire line.
Ctrl + KCut the line from the current position to the end of the line, adding it to the clipboard. If you
- `are at the beginning of the line, cut the entire line.
Ctrl + WDelete the word before the cursor, adding it to the clipboard.
Ctrl + YPaste the last thing from the clipboard that you cut recently (undo the last delete at the current cursor position).
Alt + TSwap the last two words before the cursor.
Alt + LMake lowercase from cursor to end of word.
Alt + UMake uppercase from cursor to end of word.
Alt + CCapitalize to end of word starting at cursor (whole word if cursor is at the beginning of word).
Alt + DDelete to end of word starting at cursor (whole word if cursor is at the beginning of word).
Alt + .Prints the last word written in previous command.
Ctrl + TSwap the last two characters before the cursor.
Access History through Command Line Shortcuts
Ctrl + RLets you search through previously used commands.
Ctrl + GLeave history searching mode without running a command.
Ctrl + JLets you copy current matched command to command line without running it, allowing you to make modifications before running the command.
Alt + RRevert any changes to a command you’ve pulled from your history, if you’ve edited it.
Ctrl + PShows last executed command, i.e. walk back through the command history (Similar to up arrow).
Ctrl + NShows next executed command, i.e. walk forward through the command history (Similar to down arrow).
Terminal Control Command Line Shortcuts
Ctrl + LClears the screen, similar to the clear command.
Ctrl + SStop all output to the screen. This is useful when running commands with lots of long output. But this doesn’t stop the running command.
Ctrl + QResume output to the screen after stopping it with Ctrl+S.
Ctrl + CEnd currently running process and return the prompt.
Ctrl + DLog out of the current shell session, similar to the exit or logout command. In some commands, acts as End of File signal to indicate that a file end has been reached.
Ctrl + ZSuspends (pause) currently running foreground process, which returns shell prompt. You can then use bg command allowing that process to run in the background. To again bring that process to foreground, use fg command. To view all background processes, use jobs command.
TabAuto-complete files and directory names.
Tab TabShows all possibilities, when typed characters doesn’t uniquely match to a file or directory
Ctrl + Shift + WTo close terminal tab.
Ctrl + Shift + QTo close entire terminal.
Ctrl + HSame as Backspace.
Ctrl + JSame as Return (historically Line Feed).
Ctrl + MSame as Return (historically Carriage Return).
Ctrl + ISame as Tab.
Ctrl + GBell Character.
Ctrl + @Null Character.
EscDeadkey equivalent to the
Alternatively, you can switch to the vi keybindings in bash using set -o vi. Use set -o emacs to switch back to the emacs keybindings.