The Linux command line is the most powerful tool in a developer's arsenal. Whether you're deploying servers, managing containers, automating tasks, or just navigating your system faster — terminal skills are essential for every developer.
🖥️ Why Learn the Linux Command Line?
- 90%+ of servers run Linux (AWS, Azure, GCP all default to Linux)
- Docker, Kubernetes, and CI/CD pipelines all use Linux commands
- 10x faster than using a GUI for most tasks
- Essential for DevOps, cloud engineering, and system administration
- Every macOS terminal uses Unix commands (same as Linux)
📂 File & Directory Commands
# Navigation
pwd # Print current directory
ls # List files
ls -la # List all files with details
cd /var/log # Change directory
cd .. # Go up one level
cd ~ # Go to home directory
# Creating & Removing
mkdir my-project # Create directory
mkdir -p a/b/c # Create nested directories
touch index.html # Create empty file
rm file.txt # Delete file
rm -rf folder/ # Delete folder recursively
cp file.txt backup.txt # Copy file
mv old.txt new.txt # Rename/move file
📖 Viewing & Editing Files
# View file contents
cat file.txt # Print entire file
head -20 file.txt # First 20 lines
tail -50 file.txt # Last 50 lines
tail -f /var/log/syslog # Live log streaming
less file.txt # Scrollable viewer
# Search within files
grep "error" log.txt # Find lines with "error"
grep -r "TODO" ./src/ # Recursive search
grep -i "warning" log.txt # Case-insensitive
grep -c "error" log.txt # Count matches
# Text editors
nano file.txt # Simple editor
vim file.txt # Powerful editor (press i to edit, :wq to save)
🔐 Permissions & Ownership
# View permissions
ls -la
# -rw-r--r-- 1 user group 1234 Mar 17 file.txt
# drwxr-xr-x 2 user group 4096 Mar 17 folder/
# Change permissions
chmod 755 script.sh # rwxr-xr-x (owner: all, others: read+execute)
chmod +x script.sh # Add execute permission
chmod 644 file.txt # rw-r--r--
# Change ownership
chown user:group file.txt
chown -R user:group folder/
⚙️ Process Management
# View running processes
ps aux # All processes
ps aux | grep node # Filter for node processes
top # Live process monitor
htop # Better process monitor
# Kill processes
kill 1234 # Kill by PID
kill -9 1234 # Force kill
killall node # Kill all node processes
# Background processes
./script.sh & # Run in background
nohup ./server.sh & # Run even after logout
jobs # List background jobs
🌐 Networking Commands
# Check connectivity
ping google.com
curl https://api.example.com/data
wget https://example.com/file.zip
# Network info
ifconfig # Network interfaces
ip addr # Modern alternative
netstat -tlnp # Open ports
ss -tlnp # Faster alternative
# DNS lookup
nslookup example.com
dig example.com
📜 Shell Scripting Basics
#!/bin/bash
# deploy.sh — Simple deployment script
echo "🚀 Starting deployment..."
# Variables
APP_NAME="my-app"
DEPLOY_DIR="/var/www/$APP_NAME"
# Pull latest code
cd $DEPLOY_DIR
git pull origin main
# Install dependencies
npm install --production
# Restart the app
pm2 restart $APP_NAME
echo "✅ Deployment complete!"
📚 Essential Commands Cheat Sheet
| Category | Commands |
|---|---|
| Navigation | cd, ls, pwd, find, locate |
| Files | cp, mv, rm, touch, mkdir, cat, nano |
| Search | grep, find, awk, sed, sort, uniq |
| Permissions | chmod, chown, chgrp |
| Processes | ps, top, kill, bg, fg, jobs |
| Networking | curl, wget, ping, ssh, scp, netstat |
🎯 Practice Challenge: Create a bash script that backs up a directory, compresses it with tar, and sends it to a remote server using scp. This covers files, compression, and networking — all in one exercise!