Linux Command Line: The 50 Commands Every Developer Needs (2026)
You don't need to memorize thousands of commands. These 50 cover 95% of what you'll do daily as a developer.
File & Directory Operations
# Navigation
pwd # Where am I?
cd ~/projects # Go to directory
cd - # Go to previous directory
ls -lah # List files (long, human-readable, hidden)
# Finding things
find . -name "*.js" # Find by name (recursive)
find . -type f -mtime -7 # Files modified in last 7 days
grep -r "TODO" ./src # Search file contents recursively
rg "function" ./src # Ripgrep — faster alternative
# File operations
cp file.txt backup.txt # Copy
cp -r folder/ backup/ # Copy directory
mv old.txt new.txt # Move/rename
rm file.txt # Delete (gone forever!)
rm -rf folder/ # Delete directory + contents
mkdir -p a/b/c/d # Create nested directories
touch newfile.js # Create empty file
ln -s /path/to/file link # Create symbolic link
# Viewing files
cat file.txt # Show entire file
less file.txt # Scroll through (q to quit)
head -20 file.txt # First 20 lines
tail -f logfile.log # Last lines + follow live updates!
wc -l file.txt # Count lines
du -sh * # Disk usage per item (human-readable)
Text Processing
# Search within files
grep "error" app.log # Find matching lines
grep -n "error" app.log # With line numbers
grep -C 3 "error" app.log # Show 3 lines before/after match
grep -r "import" src/ # Recursive search in directory
# Find and replace
sed 's/old/new/g' file.txt # Replace all occurrences
sed -i.bak 's/foo/bar/g' * # In-place replace with backup
# Stream editing with awk
awk '{print $1, $3}' data.txt # Print columns 1 and 3
awk '/error/{count++} END {print count}' log.txt # Count matches
# Sort & unique
sort names.txt # Alphabetical sort
sort -rn numbers.txt # Reverse numeric sort
sort file.txt | uniq -c # Count occurrences
Process Management
# What's running?
ps aux # All processes
top / htop # Interactive viewers (q to quit)
pgrep node # Find PIDs of node processes
# Controlling processes
kill PID # Graceful stop (SIGTERM)
kill -9 PID # Force kill (SIGKILL) — last resort
pkill -f "node server" # Kill by name pattern
# Background jobs
command & # Run in background
nohup long-job & # Survives terminal close
Ctrl+Z # Suspend current job
bg # Resume suspended job in background
fg # Bring to foreground
jobs # List background jobs
# Resource monitoring
free -h # Memory usage
df -h # Disk space
iotop # Disk I/O per process
nethogs # Network bandwidth per process
vmstat 1 # System stats every second
Networking
# Connection testing
ping google.com # Basic connectivity
curl -I https://example.com # HTTP headers only
curl -v https://api.test.com # Verbose request/response
# DNS
dig example.com # Full DNS info
nslookup example.com # Simple lookup
# Port checking
ss -tlnp # Listening ports + PIDs
nc -zv localhost:3000 # Test if port responds
# SSH essentials
ssh user@host # Connect to remote
ssh -i key.pem user@host # Connect with specific key
scp file.txt user@host:/path/ # Copy TO server
scp user@host:/path/file ./ # Copy FROM server
ssh-keygen -t ed25519 # Generate SSH key pair
ssh-copy-id user@host # Copy public key to server
Permissions & Users
# Permission breakdown: rwx rwx rwx
# Owner | Group | Others
# r=4, w=2, x=1 → 7=rwx, 5=r-x, 6=rw-
chmod 755 script.sh # Owner=rwx, Group+Others=rx
chmod 600 secret.key # Only owner can read/write
chown www-data:www-data /var/www/html # Change owner+group
# Sudo
sudo visudo # Edit sudoers safely
# deploy ALL=(ALL) NOPASSWD: /usr/bin/systemctl restart nginx
DevOps Essentials
# Package management (Debian/Ubuntu)
sudo apt update && sudo apt upgrade -y
sudo apt install nginx
apt search docker
# Systemd services
systemctl status nginx # Service status
systemctl start nginx # Start
systemctl restart nginx # Restart
systemctl enable nginx # Start on boot
journalctl -u nginx -f # Follow logs live
# Docker basics
docker ps # Running containers
docker images # Available images
docker exec -it container sh # Enter container
docker logs -f container # Follow logs
docker system prune -a # Clean up unused resources
# Git quick reference
git status # Working tree status
git diff # Unstaged changes
git add -A && git commit -m "msg" # Stage + commit
git push origin main # Push
git log --oneline -10 # Recent commits compact
Power User Chaining
# Pipe: output of one command = input of next
cat access.log | grep "404" | wc -l # Count 404 errors
ps aux | grep node | awk '{print $2}' | xargs kill # Kill all node procs
# Redirect output:
command > out.txt # Write to file (overwrite)
command >> out.txt # Append to file
command 2> err.txt # Write stderr to file
command < input.txt # Read from file
# Combine tools for real workflows:
# Find largest files:
du -sh * | sort -rh | head -10
# Find and delete old log files:
find /var/log -type f -mtime +30 -name "*.log" -delete
# Monitor real-time errors:
tail -f /var/log/app.log | grep --line-buffered ERROR
# Quick HTTP server from any directory:
python3 -m http.server 8000
# Batch rename (add date prefix):
for f in *.jpg; do mv "$f" "$(date +%Y%m%d)_$f"; done
# Extract any archive (universal extract function):
extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
Which command here is new to you? What's your favorite CLI trick that wasn't included?
Follow @armorbreak for more practical developer guides.
Top comments (0)