Knowing keyboard shortcuts for the Linux terminal saves hours of repetitive typing. These shortcuts work in Bash (the default shell on most Linux distributions), and most also work in Zsh and other shells that use the GNU Readline library. This reference covers cursor movement, text editing, history search, process control, and terminal management.

Cursor Movement Shortcuts

Move the cursor without reaching for the arrow keys.

ShortcutAction
Ctrl + AMove cursor to the beginning of the line
Ctrl + EMove cursor to the end of the line
Ctrl + FMove cursor one character forward (same as Right arrow)
Ctrl + BMove cursor one character backward (same as Left arrow)
Alt + FMove cursor one word forward
Alt + BMove cursor one word backward
Ctrl + XXToggle between the start of the line and current cursor position

Text Editing Shortcuts

Delete, cut, and paste text directly on the command line without a mouse.

ShortcutAction
Ctrl + UCut everything from the cursor to the beginning of the line
Ctrl + KCut everything from the cursor to the end of the line
Ctrl + WCut the word before the cursor
Alt + DCut the word after the cursor
Ctrl + YPaste the last cut text (yank)
Alt + YCycle through previously cut text (after Ctrl + Y)
Ctrl + DDelete the character under the cursor (or logout if line is empty)
Ctrl + HDelete the character before the cursor (same as Backspace)
Alt + TSwap the current word with the previous word
Ctrl + TSwap the character under the cursor with the previous one
Alt + UUppercase the word from the cursor to the end of the word
Alt + LLowercase the word from the cursor to the end of the word
Alt + CCapitalize the character under the cursor and move to end of word

Command History Shortcuts

Search and reuse previously executed commands.

ShortcutAction
Ctrl + RReverse search through command history (type to filter)
Ctrl + GCancel the reverse search and restore original line
Ctrl + PPrevious command in history (same as Up arrow)
Ctrl + NNext command in history (same as Down arrow)
Alt + .Insert the last argument from the previous command
!!Repeat the last command (useful with sudo: sudo !!)
!$Refer to the last argument of the previous command
!*Refer to all arguments of the previous command
!abcRun the most recent command starting with “abc”
!abc:pPrint the most recent command starting with “abc” without running it
^old^newRun the previous command but replace “old” with “new”

Process Control Shortcuts

Manage running processes and signals from the terminal.

ShortcutAction
Ctrl + CSend SIGINT – interrupt and stop the current foreground process
Ctrl + ZSend SIGTSTP – suspend the current process (resume with fg or bg)
Ctrl + DSend EOF – logout of the current shell session (same as exit)
Ctrl + \Send SIGQUIT – terminate the process and dump core
Ctrl + SFreeze terminal output (stop scrolling)
Ctrl + QResume terminal output (unfreeze after Ctrl + S)

Terminal and Screen Shortcuts

ShortcutAction
Ctrl + LClear the terminal screen (same as the clear command)
TabAuto-complete file names, commands, and paths
Tab TabShow all possible completions when there are multiple matches
Ctrl + _Undo the last editing action
Alt + RRevert all changes to the current line

Bang (!) History Expansion Examples

History expansion with ! is one of the most powerful time-saving features in Bash. Here are practical examples.

Rerun the last command as root:

sudo !!

Use the last argument from the previous command. If you ran mkdir /var/www/mysite, you can immediately cd into it:

cd !$

Quick substitution – fix a typo in the previous command without retyping the whole thing:

^teh^the

Run the most recent ssh command from history:

!ssh

Customize Readline Key Bindings

All Bash shortcuts are controlled by the GNU Readline library. You can view and customize bindings using the bind command or the ~/.inputrc file.

List all current key bindings:

bind -P | grep -v "not bound"

Enable case-insensitive tab completion by adding this to ~/.inputrc:

set completion-ignore-case On

Show all completions immediately without pressing Tab twice:

set show-all-if-ambiguous On

Conclusion

These shortcuts work across virtually all Linux terminals and most SSH sessions. The most impactful ones to learn first are Ctrl + R for history search, Ctrl + A / Ctrl + E for line navigation, and Ctrl + U / Ctrl + K for cutting text. For multiplexed terminal sessions with additional shortcuts, look into tmux.

Related guides:

LEAVE A REPLY

Please enter your comment!
Please enter your name here