π§ 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