Published:November 6, 2016•Updated:May 25, 2026
Larry Qu
4 min read
Linux Shell Command Line Shortcuts Complete Guide Linux Shell Command Line Shortcuts Complete Guide Linux Shell Command Line Shortcuts Complete Guide Linux Shell Command Line Shortcuts Complete Guide Linux Shell Command Line Shortcuts Complete Guide
Programming Programming Programming
Linux Linux Shell Shell Tips Tips 2026 2026
Mastering Shell command line shortcuts can greatly improve work efficiency.
Cancelling and Interrupting Commands
Ctrl + C - Interrupt Current Command
# The most common way to cancel a command# Press Ctrl + C sends SIGINT signal, terminating the currently executing command# Example: while pinging an address, want to stopping google.com
# Press Ctrl + C to stop
Ctrl + Z - Suspend Command
# Press Ctrl + Z sends SIGTSTP signal, suspending the current command# After suspension, it can be moved to the background# View background tasksjobs# Resume in foregroundfg# Resume in backgroundbg
Ctrl + D - Exit Shell
# Equivalent to typing exit# Closes the current terminal or logs out the current user
Ctrl + \ - Force Exit
# Sends SIGQUIT signal# Forcefully terminates current command, cannot be caught
Editing Commands
Moving the Cursor
Shortcut
Function
Ctrl + A
Move to beginning of line
Ctrl + E
Move to end of line
Ctrl + B
Move back one character
Ctrl + F
Move forward one character
Alt + B
Move back one word
Alt + F
Move forward one word
Deleting Text
Shortcut
Function
Ctrl + D
Delete character at cursor
Ctrl + H
Delete character before cursor (like Backspace)
Ctrl + K
Delete from cursor to end of line
Ctrl + U
Delete from cursor to beginning of line
Ctrl + W
Delete word before cursor
Alt + D
Delete word after cursor
Other Editing
Shortcut
Function
Ctrl + T
Swap character at cursor with previous character
Alt + T
Swap word at cursor with previous word
Ctrl + Y
Paste (recover) recently deleted text
Alt + .
Use last argument of previous command
Command History
Searching History
Shortcut
Function
Ctrl + P
Previous command
Ctrl + N
Next command
Ctrl + R
Reverse search history
Ctrl + G
Exit search mode
Ctrl + O
Execute current command and show next
History Expansion
# !! - Execute previous command!!
# !n - Execute the nth command!123
# !-n - Execute the nth from last command!-1
# !string - Execute the most recent command starting with string!ping
# !$ - Use last argument of previous commandcp file.txt /backup/
cd !$
# !* - Use all arguments of previous commandmkdir newdir
cd !*
Job Control
Background Jobs
# Append & to run command in background./script.sh &
# Ctrl + Z to suspend current job# Then bg to continue running in background# jobs to view background tasksjobs# fg to bring to foregroundfg %1
# bg to continue in backgroundbg %1
# kill to terminate jobkill %1
Screen Control
Shortcut
Function
Ctrl + L
Clear screen (equivalent to clear)
Ctrl + S
Pause screen output
Ctrl + Q
Resume screen output
Ctrl + P
Scroll up
Ctrl + N
Scroll down
Practical Tips
1. Safely Cancel Current Input
# Method 1: Ctrl + C# Directly cancel current line, re-enter# Method 2: Ctrl + U# Delete entire line, re-enter# Method 3: Ctrl + C then re-display# Sometimes after pasting garbled text, Ctrl+C may not be enough
2. Quick Command Correction
# Spelling correctionshopt -s cdspell # Automatically correct cd spelling errors# Case-insensitive matchingshopt -s nocaseglob # File name case-insensitive matching
3. Alias Setup
# Add common aliases in ~/.bashrcaliasll='ls -la'aliasla='ls -A'aliasl='ls -CF'# Safe delete alias (requires confirmation)aliasrm='rm -i'# Directory navigation shortcutsalias ..='cd ..'alias ...='cd ../..'alias ....='cd ../../..'
4. Quick Directory Navigation
# Quickly return to previous directorycd -
# Quickly return to home directorycd ~
cd# Quickly enter working directorycd /var/log
Common Questions
Q: A command is running, can’t type new commands?
# Ctrl + C to terminate# Ctrl + Z to suspend# Ctrl + \ to force terminate
Q: Pasted text contains special characters?
# Ctrl + U to delete current line# Then re-paste
Q: Want to cancel without deleting the command?
# Ctrl + Z to suspend# Move to background# Resume later with fg
Comments