Essential Linux Terminal Key Bindings for Efficient Command Line Editing
Mastering terminal key bindings is one of the fastest ways to improve your command-line efficiency. These shortcuts allow you to navigate, edit, and control your terminal sessions with speed and precision.
These bindings are primarily for the Bash and Zsh shells, which are the most common defaults.
Cursor Navigation
| Key Binding | Description |
|---|
Ctrl + A | Move cursor to the Beginning of the line. |
Ctrl + E | Move cursor to the End of the line. |
Alt + B | Move cursor Back one word. |
Alt + F | Move cursor Forward one word. |
Ctrl + B | Move cursor Back one character (same as Left Arrow). |
Ctrl + F | Move cursor Forward one character (same as Right Arrow). |
Text Editing
| Key Binding | Description |
|---|
Ctrl + U | Cut/Kill from cursor to the beginning of the line. |
Ctrl + K | Cut/Kill from cursor to the end of the line. |
Ctrl + W | Cut/Kill the word before the cursor. |
Alt + D | Cut/Kill the word after the cursor. |
Ctrl + Y | Paste (Yank) the last killed text. |
Ctrl + D | Delete the character under the cursor (Exit shell if line is empty). |
Ctrl + H | Delete the character before the cursor (Backspace). |
Ctrl + T | Swap the current character with the previous one. |
Alt + T | Swap the current word with the previous one. |
Ctrl + _ | Undo the last edit. |
Process Control
| Key Binding | Description |
|---|
Ctrl + C | Interrupt/Kill the current foreground process. |
Ctrl + Z | Suspend the current process (resume with fg or bg). |
Ctrl + D | Exit the current shell (End-of-File). |
Ctrl + L | Clear the terminal screen (same as clear command). |
Ctrl + S | Pause terminal output (lock the screen). |
Ctrl + Q | Resume terminal output (unlock the screen). |
History Commands
| Key Binding | Description |
|---|
Ctrl + R | Reverse Search through command history. |
Ctrl + G | Escape from history search mode. |
Up Arrow | Navigate backward through history. |
Down Arrow | Navigate forward through history. |
Ctrl + P | Previous command in history (same as Up Arrow). |
Ctrl + N | Next command in history (same as Down Arrow). |
!! | Repeat the last command. |
!<word> | Repeat the last command that started with <word>. |
Tab Completion
| Key Binding | Description |
|---|
Tab | Auto-complete file, command, or directory name. |
Tab Tab (Press twice) | Show all possible completions when ambiguous. |
Alt + * | Insert all possible completions (useful for seeing files). |
Tips for Mastery
Alt Key Note: If Alt doesn’t work (e.g., on macOS), try using the Esc key instead. Press and release Esc, then press the following key (e.g., Esc then B for Alt+B).
- The text you “cut” using
Ctrl+U, Ctrl+K, etc., is stored in a kill ring. You can yank it back with Ctrl+Y.
- Practice
Ctrl+R for searching history; it’s a massive time-saver for long or complex commands.
Integrating even a handful of these bindings into your daily workflow will dramatically speed up your interaction with the Linux terminal.