惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
博客园 - Franky
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
量子位
雷峰网
雷峰网
宝玉的分享
宝玉的分享
V
Visual Studio Blog
博客园_首页
小众软件
小众软件
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
S
SegmentFault 最新的问题
博客园 - 【当耐特】
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 叶小钗
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
人人都是产品经理
人人都是产品经理
WordPress大学
WordPress大学

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Linux Command Line: The 50 Commands You Actually Need (2026)
Alex Chen · 2026-06-05 · via DEV Community

Alex Chen

Linux Command Line: The 50 Commands You Actually Need (2026)

You don't need to memorize 10,000 commands. These 50 cover 95% of what you'll do daily as a developer.

File & Directory Operations

# Navigation
pwd                          # Print working directory (where am I?)
cd ~/projects                # Change directory (~ = home)
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 to grep

# File operations
cp file.txt backup.txt       # Copy
cp -r folder/ backup/        # Copy directory (recursive)
mv old.txt new.txt           # Move/rename
rm file.txt                  # Delete (⚠️ gone forever!)
rm -rf folder/               # Delete directory and contents (⚠️!)
mkdir -p a/b/c/d             # Create nested directories
touch newfile.js             # Create empty file (or update timestamp)
ln -s /path/to/file link     # Create symbolic link

# Viewing files
cat file.txt                 # Show entire file
less file.txt                # Scroll through file (q to quit)
head -20 file.txt            # First 20 lines
tail -f logfile.log          # Last lines + follow updates live!
wc -l file.txt               # Count lines
du -sh *                     # Disk usage per item (human-readable)

Enter fullscreen mode Exit fullscreen mode

Text Processing

# Search within files
grep "error" app.log         # Find lines containing "error"
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
grep -ri "todo" src/         # Case-insensitive recursive

# Find and replace
sed 's/old/new/g' file.txt   # Replace all occurrences (g = global)
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 (space-delimited)
awk '/error/{count++} END {print count}' log.txt # Count matching lines

# Sort & unique
sort names.txt               # Alphabetical sort
sort -rn numbers.txt         # Reverse numeric sort
uniq sorted.txt              # Remove adjacent duplicates
sort file.txt | uniq -c      # Count occurrences

# Column extraction
cut -d',' -f1,3 csv.csv     # Extract fields 1 and 3 (comma-separated)
column -t -s',' csv.csv      # Pretty-print CSV as aligned table

Enter fullscreen mode Exit fullscreen mode

Process Management

# What's running?
ps aux                       # All processes
top                          # Interactive process viewer (q to quit)
htop                         # Better top (colorful, scrollable)

# Find specific process
pgrep node                   # Find PIDs of node processes
ps aux | grep node           # Alternative: filter ps output

# Kill processes
kill PID                     # Graceful termination (SIGTERM)
kill -9 PID                 # Force kill (SIGKILL) — use as last resort
pkill -f "node server"      # Kill by name pattern
killall node                # Kill all processes named node

# Background jobs
command &                    # Run in background
jobs                         # List background jobs
fg %1                        # Bring job 1 to foreground
bg %1                        # Resume suspended job in background
Ctrl+Z                       # Suspend current job
Ctrl+C                       # Interrupt current foreground job

# Resource monitoring
free -h                      # Memory usage (human-readable)
df -h                        # Disk space per filesystem
iotop                        # Disk I/O by process
nethogs                      # Network bandwidth by process
vmstat 1                     # System stats every second

Enter fullscreen mode Exit fullscreen mode

Networking

# Connection testing
ping google.com              # Basic connectivity
curl -I https://example.com  # HTTP headers only
curl -v https://api.example.com/test  # Verbose request/response
wget https://example.com/file.zip     # Download file

# DNS lookup
dig example.com              # Full DNS info
nslookup example.com         # Simple DNS query
host example.com             # Quick lookup

# Port scanning (is something listening?)
netstat -tlnp               # Listening TCP ports + PIDs
ss -tlnp                    # Modern netstat replacement
lsof -i :3000               # What's using port 3000?

# SSH essentials
ssh user@host                # Connect to remote server
ssh -i key.pem user@host     # Connect with specific key
scp file.txt user@host:/path/  # Copy file TO server
scp user@host:/path/file ./   # Copy file FROM server
ssh-keygen -t ed25519        # Generate SSH key pair
ssh-copy-id user@host        # Copy public key to server

Enter fullscreen mode Exit fullscreen mode

Permissions & Users

# Understanding permissions: rwx rwx rwx
# Owner | Group | Others
# r=4, w=2, x=1 → 7=rwx, 5=r-x, 6=rw-

ls -la                       # Shows permissions
chmod +x script.sh           # Make executable
chmod 755 script.sh          # rwxr-xr-x (owner=full, others=read+execute)
chmod 600 secret.key         # rw------- (only owner can read/write)
chown user:group file.txt    # Change owner and group

# Sudo (run as root)
sudo command                 # Run single command as root
sudo -i                      # Switch to root shell
sudo visudo                  # Edit sudoers file safely

# User management
whoami                       # Who am I?
id                           # Current user/group info
groups                       # Which groups am I in?
last                         # Recent login history

Enter fullscreen mode Exit fullscreen mode

Package Management & DevOps

# apt (Debian/Ubuntu)
sudo apt update              # Refresh package lists
sudo apt upgrade             # Upgrade installed packages
sudo apt install nginx       # Install package
apt search docker            # Search for packages
apt show nginx               # Package details

# Systemd services
systemctl status nginx       # Service status
systemctl start nginx        # Start service
systemctl stop nginx         # Stop service
systemctl restart nginx      # Restart
systemctl enable nginx       # Start on boot
journalctl -u nginx -f       # Follow service logs live

# Docker basics
docker ps                    # Running containers
docker ps -a                 # All containers (including stopped)
docker images                # Available images
docker run -d -p 80:3000 --name myapp myimage:latest  # Run container
docker logs -f myapp         # Container logs (follow)
docker exec -it myapp bash   # Enter running container
docker-compose up -d         # Start all services from compose file
docker system prune -a       # Clean up unused images/containers

# Git (quick reference)
git status                   # Working tree status
git diff                      # Unstaged changes
git add -A && git commit -m "msg"  # Stage all + commit
git push origin main          # Push to remote
git pull origin main          # Pull from remote
git log --oneline -10         # Recent commits compact
git stash                     # Save changes temporarily

Enter fullscreen mode Exit fullscreen mode

The Real Power: Chaining Commands

# 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 > output.txt          # Write to file (overwrite)
command >> output.txt         # Append to file
command 2> errors.txt         # Write stderr to file
command > out.txt 2>&1        # Both stdout and stderr to file
command < input.txt           # Read from file instead of stdin

# Combine tools for real workflows:

# Find largest files in current directory:
du -ah | sort -rh | head -10

# Find and delete files older than 30 days:
find . -type f -mtime +30 -name "*.log" -delete

# Monitor real-time errors in logs:
tail -f /var/log/app.log | grep --line-buffered ERROR

# Batch rename files (add date prefix):
for f in *.jpg; do mv "$f" "$(date +%Y%m%d)_$f"; done

# Quick HTTP server from any directory:
python3 -m http.server 8000    # Serve current dir on port 8000
# Or: npx serve .

# Quick port check:
nc -zv localhost 3000 && echo "Port open" || echo "Port closed"

# Extract any archive (works for tar, zip, gz, etc):
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
}
# Add this function to your ~/.bashrc!

Enter fullscreen mode Exit fullscreen mode


Which command here is new to you? What's your favorite CLI trick that wasn't included?

Follow @armorbreak for more practical developer guides.