~2 min read • Updated Jul 18, 2025

1. Editing Commands with Readline


Bash uses the Readline library, which supports rich editing, navigation, and clipboard operations directly from the terminal.


Cursor Movement Keys


KeyAction
Ctrl+AMove to beginning of line
Ctrl+EMove to end of line
Ctrl+F / →Forward one character
Ctrl+B / ←Backward one character
Alt+FForward one word
Alt+BBackward one word
Ctrl+LClear screen

Text Editing Shortcuts


KeyAction
Ctrl+DDelete current character
Ctrl+TTranspose character with previous
Alt+TTranspose current and previous word
Alt+LLowercase to end of word
Alt+UUppercase to end of word

2. Cutting and Pasting with Kill & Yank


Text is cut into a buffer (kill-ring) and pasted using:


KeyAction
Ctrl+KKill to end of line
Ctrl+UKill to beginning of line
Alt+DKill to end of word
Alt+BackspaceKill to beginning of word
Ctrl+YYank (paste) last killed text

3. Autocompletion with Tab


Pressing TAB completes filenames, commands, directories, and more:



ls l[TAB] → ls-output.txt
ls Do[TAB] → Documents

Supported Completions:


  • File/directory paths
  • Environment variables like $HO[TAB]
  • Usernames ~user
  • System commands
  • Hosts from /etc/hosts

Additional Keys:


KeyAction
Alt + ?List all completions
Alt + *Insert all matching items

4. Command History Management



history | less
history | grep /usr/bin
!88          # Run command number 88

Interactive Search (Ctrl+R):


  • Ctrl+R → Start reverse search
  • Ctrl+J → Insert and edit command
  • Ctrl+G → Cancel search

Navigation Shortcuts


KeyAction
Ctrl+P / ↑Previous command
Ctrl+N / ↓Next command
Alt+<First command in history
Alt+>Last command in history
Ctrl+ORun current command and move to next

5. History Expansion with !


PatternAction
!!Run last command
!numberRun specific numbered command
!stringRun last command starting with string
!?stringRun last command containing string

⚠ Caution: History expansion can trigger unexpected results. Always verify before executing.


6. Recording a Terminal Session



script log.txt        # Saves all terminal activity to log.txt
exit                  # Stop recording

Conclusion


Bash power users rely on the keyboard and its rich shortcut set to streamline their workflow. By mastering Readline edits, autocompletion, history tricks, and efficient command expansion, you can elevate your shell experience to pro level—where speed meets precision.


Written & researched by Dr. Shahin Siami