419 Words

🧠 Linux CLI Cheatsheet (Daily Use)

πŸ”Ž Search in History

Ctrl + r        # Reverse search (type to search, keep pressing for older matches)
Ctrl + s        # Forward search (often disabled by default)

history         # Show command history
history | grep ssh   # Search history with grep

!123            # Run command number 123 from history
!!              # Run last command
!ssh            # Run last command starting with "ssh"

✏️ Cursor Movement (SUPER useful)

Ctrl + a        # Go to beginning of line
Ctrl + e        # Go to end of line
Alt + b         # Move back one word
Alt + f         # Move forward one word
Ctrl + x Ctrl + x  # Jump between start of line and cursor
Alt + .         # Insert the last argument of the previous command (press again for older ones)

βœ‚οΈ Editing & Deleting

Ctrl + u        # Delete from cursor β†’ start
Ctrl + k        # Delete from cursor β†’ end
Ctrl + w        # Delete previous word
Ctrl + d        # Delete character under cursor
Ctrl + h        # Delete character before cursor (backspace)

Ctrl + y        # Paste last deleted text (yank)
Ctrl + _        # Undo the last edit

🧹 Clear Screen / Reset

Ctrl + l        # Clear screen (same as 'clear')
clear           # Clear screen
reset           # Full terminal reset (fix broken terminal)

⏸️ Process Control

Ctrl + c        # Stop current command
Ctrl + z        # Pause (stop) the command; continue it with fg or bg

fg              # Bring back to foreground
bg              # Resume in background
jobs            # List background jobs

πŸ“ Navigation & Basics

cd -            # Go to previous directory
pwd             # Show current directory
ls -lah         # List files (detailed + human readable)

tree            # Show directory structure (if installed)

⚑ Handy Shortcuts

Tab             # Auto-complete files/commands
Tab Tab         # Show all possibilities

Ctrl + p        # Previous command (like ↑)
Ctrl + n        # Next command (like ↓)

🧠 Pro Tips

sudo !!         # Rerun last command with sudo

!$              # Last argument of previous command
# example:
mkdir test
cd !$           # goes into test

^old^new        # Replace text in last command
# example:
ls /var/logg
^logg^log       # fixes typo

🧼 Clear History (careful πŸ˜„)

history -c      # Clear current session history
history -w      # Write changes to ~/.bash_history

πŸ”§ Bonus (zsh / oh-my-zsh)

Ctrl + r        # History search

# Install fzf for an even better search:
# Ctrl + r becomes an interactive fuzzy search