Linux CLI 15 🐧 shortcuts
Mastering keyboard shortcuts is the fastest way to boost your productivity in the terminal. Once these become muscle memory, you’ll navigate and edit commands at lightning speed — without ever touching the arrow keys.
Moving Around the Line
| Shortcut | Action |
|---|---|
Ctrl + A | Move cursor to the beginning of the line |
Ctrl + E | Move cursor to the end of the line |
Alt + B | Move back one word |
Alt + F | Move forward one word |
Examples:
$ ls -la /var/log/myservice/debug.log
# Cursor at the end (after "log")
# Press Ctrl+A → cursor moves to start of line
# Press Ctrl+E → cursor back at end
Editing and Deleting
| Shortcut | Action |
|---|---|
Ctrl + H | Delete the character to the left of the cursor |
Ctrl + W | Kill (delete) the word to the left |
Alt + D | Kill from cursor to the end of the word |
Alt + Backspace | Kill from cursor to the beginning of the word |
Examples:
$ echo "hello world foo bar"
# Cursor after "bar"
# Ctrl+W → deletes "bar", now: echo "hello world foo
# Ctrl+W again → deletes "foo", now: echo "hello world
Cutting and Pasting (Kill/Yank)
| Shortcut | Action |
|---|---|
Ctrl + K | Cut from cursor to the end of the line |
Ctrl + U | Cut from cursor to the beginning of the line |
Ctrl + Shift + K | Cut from cursor to end of line, save in kill buffer |
Ctrl + Y | Paste text from kill buffer at cursor |
Examples:
Cut and reorder:
$ cp /source/file.txt /destination/file.txt
# Cut the destination part with Ctrl+K
$ cp /source/file.txt /destination/file.txt
# Ctrl+K → "cp /source/file.txt /destination/" (line now "cp /source/file.txt ")
# Ctrl+Y → pastes "/destination/file.txt" (back to original)
Move to start of line:
$ cd /home/kronos/Documents
# Cursor at end of line
# Ctrl+U → cuts "/home/kronos/Documents", leaving "cd "
# Type " " + Ctrl+Y → "cd /home/kronos/Documents"
Practical: swap arguments
$ mv oldname.txt newname.txt
# Cursor at end
# Ctrl+W → cuts "newname.txt"
# Ctrl+W → cuts "oldname.txt"
# Type " " then Ctrl+Y → pastes "oldname.txt"
# Type " " then Ctrl+Y → pastes "newname.txt"
# Result: mv oldname.txt newname.txt (still the same)
# Or with Ctrl+K:
$ mv oldname.txt newname.txt
# Ctrl+A (start of line)
# Ctrl+K (cut whole line)
# Ctrl+Y (paste back)
History Navigation
| Shortcut | Action |
|---|---|
Ctrl + R | Reverse search through command history |
Ctrl + P | Go back in command history (like ↑) |
Ctrl + N | Go forward in command history (like ↓) |
Ctrl + R — Reverse Search
The most powerful shortcut in this list!
How it works:
- Press
Ctrl + R - Start typing a keyword
- The most recent matching command appears
- Press
Ctrl + Ragain to go further back - Press
Enterto run or→to edit
Example:
(reverse-i-search)`git': git commit -m "fix: update readme"
# Press Ctrl+R again → previous command containing "git"
(reverse-i-search)`git': git status
# Press Enter → runs "git status"
# Or press → to edit it before running
Exiting search:
Ctrl + C— cancelEnter— run the matched commandEsc— exit search but keep the line→/←— exit and edit
Ctrl + P / Ctrl + N — History Navigation
| Key | Same as |
|---|---|
Ctrl + P | ↑ (previous) |
Ctrl + N | ↓ (next) |
Example:
$ date
$ cal
$ pwd
# Press Ctrl+P three times → date
# Press Ctrl+N twice → pwd
Screen and Terminal Control
| Shortcut | Action |
|---|---|
Ctrl + L | Clear the screen (like clear command) |
Ctrl + J | Enter a new line without moving to next tab stop |
Ctrl + X | Exit current mode back to command line |
Examples:
Clear screen:
$ ls -la
# (lots of output)
# Ctrl+L → clean screen, prompt at top
Multi-line command (Ctrl + J):
$ echo "Line 1" && \
> echo "Line 2"
# Or use Ctrl+J to insert a newline without running
Copy and Paste
| Shortcut | Action |
|---|---|
Ctrl + Shift + C | Copy selected text to clipboard |
Ctrl + Shift + V | Paste text from clipboard |
Note: These are terminal emulator shortcuts, not shell shortcuts. They work in most Linux terminals (GNOME Terminal, Konsole, xfce4-terminal).
Why Ctrl+Shift+C instead of Ctrl+C?
Ctrl + Cis reserved by the shell to cancel the current command- Terminal emulators use
Ctrl + Shift + Cfor copying
Examples:
# Select text with mouse
# Ctrl+Shift+C → copy
# Ctrl+Shift+V → paste into another command or editor
Complete Shortcut Reference Table
Cursor Movement
| Shortcut | Action |
|---|---|
Ctrl + A | Beginning of line |
Ctrl + E | End of line |
Alt + B | Back one word |
Alt + F | Forward one word |
Editing
| Shortcut | Action |
|---|---|
Ctrl + H | Delete character left of cursor |
Ctrl + W | Delete word left of cursor |
Alt + D | Delete word right of cursor |
Alt + Backspace | Delete word left of cursor |
Kill/Yank (Cut/Paste)
| Shortcut | Action |
|---|---|
Ctrl + K | Cut to end of line |
Ctrl + U | Cut to beginning of line |
Ctrl + Shift + K | Cut to end (save in kill buffer) |
Ctrl + Y | Paste from kill buffer |
History
| Shortcut | Action |
|---|---|
Ctrl + R | Reverse search |
Ctrl + P | Previous command (like ↑) |
Ctrl + N | Next command (like ↓) |
Terminal
| Shortcut | Action |
|---|---|
Ctrl + L | Clear screen |
Ctrl + J | New line (no tab stop) |
Ctrl + X | Exit current mode |
Ctrl + Shift + C | Copy to clipboard |
Ctrl + Shift + V | Paste from clipboard |
Complete Example Session
Let’s walk through real scenarios:
# ============================================
# SCENARIO 1: FIX A TYPO IN A LONG COMMAND
# ============================================
$ cp /home/kronos/Documents/important-file.txt /backup/
# Oops! Forgot the destination is "/backup/"
# Actually, we meant "/mnt/backup/"
# Cursor is at end of line
# Ctrl+A → cursor to start
# Alt+F × 3 → forward 3 words
# ... but this is slow
# Better: Ctrl+W → deletes "/backup/"
# Type "/mnt/backup/" + Enter
# ============================================
# SCENARIO 2: SEARCH FOR A PREVIOUS COMMAND
# ============================================
$ git commit -m "initial commit"
$ git push origin main
$ npm install
$ docker build -t myapp .
$ git log
# Now you want to run "git push" again
# Ctrl+R → type "push"
(reverse-i-search)`push': git push origin main
# Press Enter → runs it again
# ============================================
# SCENARIO 3: SWAP TWO WORDS
# ============================================
$ mv file2.txt file1.txt
# Oops! Should be: mv file1.txt file2.txt
# Cursor at end of line
# Ctrl+W → deletes "file2.txt"
# Ctrl+W → deletes "file1.txt"
# Type " " + Ctrl+Y → pastes "file1.txt"
# Type " " + Ctrl+Y → pastes "file2.txt"
# Result: mv file1.txt file2.txt ✅
# ============================================
# SCENARIO 4: CLEAR SCREEN QUICKLY
# ============================================
$ cat /var/log/syslog
# (floods screen with output)
# Ctrl+L → clean screen, back to prompt
# ============================================
# SCENARIO 5: COPY OUTPUT TO ANOTHER APP
# ============================================
$ ls -la
# Select relevant lines with mouse
# Ctrl+Shift+C → copied
# Switch to editor/browser
# Ctrl+V (or Cmd+V on Mac) → pasted
# ============================================
# SCENARIO 6: CANCEL A HUNG COMMAND
# ============================================
$ find / -name "*.log"
# (takes forever)
# Ctrl+C → cancels the command
# Note: Ctrl+C cancels; Ctrl+Shift+C copies!
Kill Buffer Explained
The kill buffer is a temporary storage in the shell where cut text goes. Ctrl + Y (Yank) pastes from it.
| Action | Shortcut |
|---|---|
| Cut text | Ctrl + K, Ctrl + U, Ctrl + W, Alt + D |
| Paste cut text | Ctrl + Y |
Key points:
- The kill buffer holds the last cut text
- Multiple cuts append to the buffer
Ctrl + Ypastes it back at cursor position- Buffer is session-only — not saved between terminals
Example — kill buffer with multiple cuts:
$ echo "line1 line2 line3"
# Ctrl+W → cuts "line3"
# Ctrl+W → cuts "line2" (appended)
# Now buffer contains "line2 line3"
# Ctrl+Y → pastes "line2 line3"
# Result: echo "line1 line2 line3"
Best Practices
✅ Do This:
# Learn Ctrl+R first
Ctrl+R # Then type a keyword
# Use Ctrl+L instead of typing "clear"
Ctrl+L # Faster than clear + Enter
# Use Ctrl+A / Ctrl+E to jump
Ctrl+A # Start of line
Ctrl+E # End of line
# Use Ctrl+W to delete a whole word
Ctrl+W # Faster than Backspace
# Use Ctrl+U to clear a line you regret
Ctrl+U # Cuts entire line to start
# Use Ctrl+Y to bring back cut text
Ctrl+Y # Paste from kill buffer
❌ Don’t Do This:
# Don't use arrow keys for everything
# ↑↑↑↓←←→→ → Slower than Ctrl+R
# Don't use Ctrl+C to copy
Ctrl+C # ❌ Cancels the command!
Ctrl+Shift+C # ✅ Copies
# Don't forget Ctrl+Shift+C for copy
# In Linux terminals, Ctrl+C ≠ copy!
# Don't backspace a whole word
# Hold Backspace → Slow
Ctrl+W # ✅ Instant
# Don't retype a long command
# Just press ↑ or use Ctrl+R
Common Pitfalls
| Pitfall | Problem | Solution |
|---|---|---|
Ctrl+C to copy | Cancels command | Use Ctrl+Shift+C |
Ctrl+V to paste | Inserts literal character | Use Ctrl+Shift+V |
Ctrl+K to save text | Cuts and saves in kill buffer | Use Ctrl+Y to paste back |
| Arrow keys only | Slow history navigation | Use Ctrl+R |
Forget Ctrl+L | Type clear manually | Ctrl+L is instant |
Confusing Ctrl+P/N | Same as ↑/↓ | Use whichever feels natural |
Real-World Use Cases
1. Editing a Long File Path
$ cp /home/kronos/projects/webapp/src/components/Header.jsx /backup/components/
# Cursor at end
# Ctrl+A → go to start
# Alt+F × 6 → move to "/backup/"
# Ctrl+W → delete the destination
# Type "/mnt/backup/Header.jsx"
# Press Enter
2. Rerunning a Previous Command with Edits
$ docker run -p 8080:80 nginx
# Ctrl+P → same command
# Ctrl+A → start
# Ctrl+F → navigate to "8080"
# Edit to "3000"
# Enter
3. Searching History for a Complex Command
$ ssh -i ~/.ssh/prod-key.pem ubuntu@10.0.1.5 -p 2222
# Later...
# Ctrl+R → type "ubuntu"
(reverse-i-search)`ubuntu': ssh -i ~/.ssh/prod-key.pem ubuntu@10.0.1.5 -p 2222
# Enter → reruns it
4. Reordering Arguments
$ chmod 755 script.sh
# Oops, want: chmod script.sh 755? No — order matters
# Actually: chmod 755 script.sh is correct
# But if you wanted to swap:
$ chmod 755 script.sh
# Ctrl+A → start
# Ctrl+W × 3 → delete "chmod 755 script.sh" word by word
# Type "chmod script.sh 755" (hypothetical)
5. Multi-Line Command Entry
$ for i in {1..5}; do
> echo "Number: $i"
> done
# Each line is prompted with ">" to continue
# Use Ctrl+C to cancel if needed
Customizing Shortcuts (Bonus)
You can customize shortcuts in ~/.inputrc:
# ~/.inputrc
"\C-t": "hello world" # Ctrl+T inserts "hello world"
"\C-g": kill-whole-line # Ctrl+G kills the whole line
"\e[1;5C": forward-word # Ctrl+Right → forward word
"\e[1;5D": backward-word # Ctrl+Left → backward word
After editing:
$ bind -f ~/.inputrc
# Or restart the shell
Summary
| Category | Key Shortcuts |
|---|---|
| Navigation | Ctrl+A (start), Ctrl+E (end), Alt+B/F (words) |
| Editing | Ctrl+H (delete), Ctrl+W (delete word) |
| Cut/Paste | Ctrl+K (cut end), Ctrl+U (cut start), Ctrl+Y (paste) |
| History | Ctrl+R (search), Ctrl+P/N (prev/next) |
| Screen | Ctrl+L (clear), Ctrl+J (newline) |
| Clipboard | Ctrl+Shift+C (copy), Ctrl+Shift+V (paste) |
Key takeaways:
Ctrl + Ris the single most powerful shortcut — use it constantlyCtrl + AandCtrl + Ejump to start and end of lineCtrl + Wdeletes a whole word — faster than mashing BackspaceCtrl + KandCtrl + Ucut to end or start of lineCtrl + Ypastes back from the kill buffer — your safety netCtrl + Lclears the screen instantly — no need forclearCtrl + Shift + C/Vfor copy/paste — becauseCtrl + Ccancels commandsCtrl + PandCtrl + Nare the same as ↑ and ↓
Remember: Learning just 5 of these shortcuts — Ctrl+R, Ctrl+A, Ctrl+E, Ctrl+W, and Ctrl+L — will make you noticeably faster. The single most important is Ctrl+R for reverse history search. Once it clicks, you’ll wonder how you ever lived without it. And always remember the golden rule: Ctrl + C cancels commands — Ctrl + Shift + C copies text!
Stop using slow, ad-bloated tool sites! 🤮
🔎 Search “KandZ Tools” on Google to use many professional utilities for free.
KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)
⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free
🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!