Terminal Command Mastery

Unleash the full potential of your Linux system with this expert-curated collection of essential commands, advanced techniques, and professional workflow tips.

File Operations

ls

-l (long), -a (all), -h (human)

List directory contents

ls -lah

💡 Pro Tip: Add alias ll='ls -alF' to .bashrc

find

-type (f/d), -mtime (modified)

Search for files

find / -name '*.conf'

rsync

Advanced file sync

rsync -avz source/ user@remote:dest/

💡 Pro Tip: Great for backups and migrations

ln

-s (symbolic)

Create links

ln -s /path/file linkname

tar

-czf (compress), -xzf (extract)

Archive files

tar -czf archive.tar.gz folder/

touch

Create an empty file or update the timestamp

touch file.txt

System Insights

htop

Interactive process viewer

htop

💡 Pro Tip: F2 to configure display

journalctl

Systemd logs viewer

journalctl -u nginx --since '1h ago'

lsof

List open files

lsof -i :80

dmesg

-T (timestamps), -w (follow)

Kernel ring buffer

uptime

Show how long the system has been running

uptime

free

Display memory usage

free -m

df

Show disk space usage

df -h

top

Display running processes

top

Text Wizardry

grep

-A/B/C (context lines)

Pattern search

grep -rin 'error' /var/log

awk

Text processing

awk '{sum+=$1} END{print sum}' data.txt

jq

JSON processor

curl api | jq '.data[].name'

sort | uniq

Unique entries

cat log | sort | uniq -c

cut

Remove sections from each line of files

cut -d ' ' -f 1 file.txt

paste

Merge lines of files

paste file1.txt file2.txt

wc

Count lines, words, and characters in files

wc -l file.txt

Network Ninja

ssh

Secure shell

ssh -i ~/.ssh/key.pem user@host

💡 Pro Tip: Use ssh-copy-id for key auth

tcpdump

Network sniffer

tcpdump -i eth0 port 80

dig

DNS lookup

dig +short example.com A

netstat

Network stats

netstat -tulpn

wget

Download files from the web

wget https://example.com/file.zip

curl

Transfer data from or to a server

curl -LO https://example.com/file.zip

Process Control

kill

Signal processes

kill -9 1234

💡 Pro Tip: Use kill -l to list signals

nohup

Run persistent

nohup ./script.sh &

cron

Schedule tasks

💡 Pro Tip: Use crontab -e to edit jobs

systemd

Service management

systemctl restart nginx

Power User Techniques

Command Chaining

Combine commands with && or || operators:

make && make install || echo 'Build failed'

History Power

Reuse commands efficiently:

â–¹!! - Repeat last command
â–¹!$ - Last argument of prev command
â–¹Ctrl+R - Reverse search

Alias Magic

Create shortcuts in ~/.bashrc:

alias update='sudo apt update && sudo apt upgrade'

Ready to become a terminal wizard?