The Essentials Everyone Should Know
| Command | What It Does |
|---|---|
| man <command> | Read the manual for any command |
| <command> --help | Quick help for most commands |
| history | Show your command history |
| !! | Re-run the last command |
| !$ | Use the last argument of the previous command |
| Ctrl + R | Reverse-search your command history |
| Ctrl + L | Clear the terminal screen |
| Ctrl + C | Kill the running command |
| Ctrl + D | Exit the terminal / send EOF |
| Tab | Auto-complete file names & commands |
| Tab Tab | Show all possible completions |
File & Directory Navigation
bashcd - # Jump back to the previous directory
cd ~ # Go to your home directory
pushd /tmp && popd # Save & return to a directory
ls -lah # Human-readable sizes, hidden files, long format
ls -lt # Sort by modification time (newest first)
tree -L 2 # Show directory tree, 2 levels deep
find . -name "*.log" -mtime +7 # Find .log files older than 7 days
Pro tip: Use zoxide or autojump for smarter cd โ it learns your most-used directories.
bash
z project # Jumps to your most-visited "project" folder
Searching Like a Pro
bashgrep -rin "error" /var/log/ # Recursive, case-insensitive, line numbers
grep -v "debug" app.log # Invert match (exclude lines)
rg "pattern" . # ripgrep โ blazing fast alternative
find . -type f -exec grep -l "TODO" {} + # Files containing TODO
locate filename # Instant search (run
sudo updatedb first)ripgrep (rg) is a modern replacement for grep โ install it with sudo apt install ripgrep.
History & Aliases
bashalias ll='ls -lah' # Create a shortcut
alias ..='cd ..' # Quick parent dir
alias gs='git status'
unalias ll # Remove an alias
Make aliases permanent โ add them to ~/.bashrc or ~/.zshrc:
bash
echo "alias ll='ls -lah'" >> ~/.bashrc
source ~/.bashrc
History tricks:
bash
history | grep ssh # Find past ssh commands
!123 # Run command #123 from history
sudo !!
*****, Redirection & Chaining
bashcommand > file # Overwrite file
command >> file # Append to file
command 2> error.log # Redirect stderr only
command &> all.log # Redirect both stdout & stderr
command1 && command2 # Run cmd2 only if cmd1 succeeds
command1 || command2 # Run cmd2 only if cmd1 fails
command1 | tee out.txt # Show output AND save to file
Real-world example:
bash
ps aux | grep nginx | grep -v grep | awk '{print $2}' | xargs kill -9
Process Management
bashhtop # Interactive process viewer (better than top)
ps aux | grep <name> # Find a process
pgrep -af <name> # Find process by name with full command
kill -9 <PID> # Force kill
pkill -f "python app.py" # Kill by command pattern
nohup ./script.sh & # Run in background, survives logout
disown # Detach a running job from the shell
Background job control:
bash
Ctrl + Z # Suspend current process
bg # Resume it in the background
fg # Bring it back to foreground
jobs # List background jobs
Permissions & Ownership
bashchmod +x script.sh # Make executable
chmod 755 file # rwxr-xr-x
chmod 644 file # rw-r--r--
chown user:group file # Change owner and group
chown -R user:group dir/ # Recursive
umask 022 # Default permission mask
Quick octal reference:
| Value | Permission |
|---|---|
| 7 | rwx |
| 6 | rw- |
| 5 | r-x |
| 4 | r-- |
| 0 | --- |
Networking
baship a # Show IP addresses (modern replacement for ifconfig)
ip r # Show routing table
ss -tulnp # Show listening ports (better than netstat)
curl -I You do not have permission to view the full content of this post. Log in or register now. # Get HTTP headers only
curl -O You do not have permission to view the full content of this post. Log in or register now. # Download file
wget -c You do not have permission to view the full content of this post. Log in or register now. # Resume a partial download
ping -c 4 google.com
traceroute google.com
nmap -sV 192.168.1.1 # Scan ports & services
Transfer files:
bash
scp file.txt user@host:/path/ # Copy to remote
rsync -avz --progress src/ user@host:/dst/ # Sync with progress
Disk & Storage
bashdf -h # Disk space (human-readable)
du -sh * # Size of each item in current dir
du -sh */ | sort -h # Sorted by size
ncdu # Interactive disk usage explorer
lsblk # List block devices
mount | column -t # Show mounts nicely
Find largest files:
bash
find / -type f -size +100M 2>/dev/null
Text Processing Power Moves
bashawk '{print $1, $3}' file.txt # Print columns 1 and 3
sed 's/old/new/g' file.txt # Replace all occurrences
sort file.txt | uniq -c | sort -rn # Count duplicates, sort by frequency
cut -d',' -f2 data.csv # Get 2nd CSV column
tr 'a-z' 'A-Z' < file.txt # Uppercase
head -n 20 file.txt # First 20 lines
tail -f /var/log/syslog # Follow a log live
wc -l file.txt # Count lines
One-liner: top 10 most frequent words in a file
bash
tr -c '[:alnum:]' '[\n*]' < file.txt | sort | uniq -c | sort -rn | head
Handy System Info
bashuname -a # Kernel & system info
lsb_release -a # Distro info
lscpu # CPU details
free -h # RAM usage
uptime # How long system has been running
whoami # Current user
id # User & group IDs
neofetch # Pretty system summary (install separately)
Package Management Cheatsheet
Debian/Ubuntu (apt):bash
sudo apt update && sudo apt upgrade -y
sudo apt install <pkg>
sudo apt remove <pkg>
apt search <term>
dpkg -l | grep <pkg>
Fedora/RHEL (dnf):
bash
sudo dnf install <pkg>
sudo dnf upgrade --refresh
Arch (pacman):
bash
sudo pacman -Syu
sudo pacman -S <pkg>
Universal:
bash
snap install <pkg>
flatpak install <pkg>
Power User Tricks
1. Run a command as another user
bashsudo -u www-data ls /var/www
2. Watch a command's output repeatedly
bashwatch -n 2 'df -h'
3. Create a file instantly
bashtouch newfile.txt # Also emptynewfile.txt # Empty file
4. Extract any archive
bashtar -xzvf file.tar.gz
tar -xjvf file.tar.bz2
unzip file.zip
7z x file.7z
5. Create a tarball
bashtar -czvf backup.tar.gz /path/to/folder
6. Compare two files
bashdiff file1 file2
vimdiff file1 file2 # Side-by-side in vim
7. Generate a random password
bashopenssl rand -base64 16
8. Serve current directory over HTTP
bashpython3 -m http.server 8000
9. SSH without password (key-based auth)
bashssh-keygen -t ed25519
ssh-copy-id user@host
10. Keep SSH sessions alive
Add to ~/.ssh/config:text
Host *
ServerAliveInterval 60
Must-Have Modern Tools
| Tool | Replaces | Why |
|---|---|---|
| ripgrep (rg) | grep | Faster, respects .gitignore |
| fd | find | Simpler syntax, faster |
| bat | cat | Syntax highlighting + git diff |
| eza / exa | ls | Icons, colors, tree view |
| zoxide | cd | Smarter directory jumping |
| fzf | โ | Fuzzy finder for everything |
| tmux | screen | Terminal multiplexer |
| jq | โ | Parse JSON in terminal |
| htop | top | Better process viewer |
| ncdu | du | Interactive disk usage |
bash
sudo apt install ripgrep fd-find bat fzf jq htop ncdu tmux
FZF: The Game Changer
Install fzf and add this to your ~/.bashrc:bash
# Ctrl+R for fuzzy history search
# Ctrl+T for fuzzy file finder
# Alt+C for fuzzy cd
Killer combos:
bash
vim $(fzf) # Open a file from fuzzy search
kill -9 $(ps aux | fzf | awk '{print $2}')
Resources
You do not have permission to view the full content of this post.
Log in or register now.
You do not have permission to view the full content of this post.
Log in or register now. โ paste a command, get an explanation
You do not have permission to view the full content of this post.
Log in or register now. โ simplified man pages
You do not have permission to view the full content of this post.
Log in or register now.
You do not have permission to view the full content of this post.
Log in or register now. โ learn by playing
TL;DR: Master Tab, Ctrl+R, *****, and fzf. Then add ripgrep, fd, bat, and zoxide. You'll feel like a wizard in a week.
