DEV Community

Alex Chen
Alex Chen

Posted on

Designing a REST API That Developers Actually Like Using

30 Linux Commands I Use Every Day as a Developer

The exact commands I run on my VPS every single day.

File Operations

# Find files by name
find . -name "*.js" -not -path "*/node_modules/*"

# Find files modified recently (last 7 days)
find . -mtime -7 -type f

# Find large files (>100MB)
find /var/log -size +100M

# Search file contents
grep -r "TODO" src/ --include="*.js" -n

# Better grep with ripgrep (rg)
rg "functionName" --type js --context 2

# Quick file preview
head -n 20 app.js        # First 20 lines
tail -f /var/log/nginx.log # Follow log live
tail -n 50 error.log      # Last 50 lines
wc -l *.js                # Line counts
Enter fullscreen mode Exit fullscreen mode

Disk & Memory

# Disk usage overview
df -h

# Directory sizes (sorted)
du -sh * | sort -hr

# What's eating disk space?
du -a /var | sort -nr | head -20

# Memory usage
free -h

# Top memory consumers
ps aux --sort=-%mem | head -10

# Real-time resource monitoring
htop          # Better top
iotop         # Disk I/O
iftop         # Network traffic
Enter fullscreen mode Exit fullscreen mode

Process Management

# Find process
ps aux | grep node
pgrep -f "node server"    # Just PIDs

# Kill process
kill 12345                 # Graceful
kill -9 12345              # Force kill
pkill -f "node server"     # Kill by name pattern

# Background & foreground
node server.js &           # Run in background
jobs                       # List background jobs
fg %1                      # Bring job 1 to foreground
Ctrl+Z                     # Suspend current job
bg                         # Resume suspended in background

# Keep running after logout
nohup node server.js > output.log 2>&1 &
# or better: use systemd/tmux/screen
Enter fullscreen mode Exit fullscreen mode

Networking

# Test connectivity
curl -I https://example.com       # Headers only
curl -s https://api.example.com   # Silent mode
wget -qO- https://example.com     # Alternative to curl

# Port check
ss -tlnp | grep :3000             # Who's listening on port 3000?
netstat -tlnp | grep 80           # Alternative

# DNS lookup
dig example.com                    # Full DNS info
nslookup example.com              # Simple lookup

# Test connection
nc -zv localhost 3000              # Is port open?

# Download/upload speed test
curl -o /dev/null -w "%{speed_download}" http://speedtest.tele2.net/10MB.zip
Enter fullscreen mode Exit fullscreen mode

Text Processing

# View file contents
cat config.json
less huge.log                      # Paginated view (q to quit)

# Column extraction
awk '{print $1, $3}' access.log    # Columns 1 and 3
cut -d',' -f2 data.csv            # CSV column 2

# Sort & unique
sort names.txt | uniq              # Remove duplicates
sort names.txt | uniq -c           # Count occurrences

# Replace text
sed -i 's/old/new/g' file.txt     # In-place replace

# Stream editing
tail -f app.log | grep ERROR       # Live filter logs
Enter fullscreen mode Exit fullscreen mode

Permissions

# Current permissions
ls -la

# Change permissions
chmod +x script.sh                 # Make executable
chmod 644 file.txt                 # rw-r--r--
chmod 755 directory/               # rwxr-xr-x

# Change owner
chown user:group file.txt
chown -R www-data:www-data /var/www/

# Fix common permission issues
chmod -R 755 /var/www/html
find /var/www/html -type f -exec chmod 644 {} \;
Enter fullscreen mode Exit fullscreen mode

Archives

# Create tar.gz
tar -czvf archive.tar.gz folder/

# Extract
tar -xzvf archive.tar.gz
tar -xjf archive.tar.bz2           # bz2 format

# Zip/unzip
zip -r backup.zip folder/
unzip backup.zip

# Create without parent directory
cd source && tar -czvf ../backup.tar.gz *
Enter fullscreen mode Exit fullscreen mode

SSH & Remote

# Connect
ssh user@hostname

# Copy files
scp file.txt user@host:/path/to/
scp -r folder/ user@host:/path/

# Key-based auth (no password!)
ssh-keygen -t ed25519
ssh-copy-id user@hostname

# Port forwarding (tunnel local port to remote)
ssh -L 8080:localhost:3000 user@host

# Config shortcuts (~/.ssh/config)
Host production
    HostName 192.168.1.100
    User deploy
    IdentityFile ~/.ssh/id_ed25519
# Now: ssh production
Enter fullscreen mode Exit fullscreen mode

Systemd Services

# Status
systemctl status nginx
systemctl status my-app

# Start/stop/restart
sudo systemctl restart nginx
sudo systemctl start my-app
sudo systemctl stop my-app

# Enable on boot
sudo systemctl enable my-app

# View logs
journalctl -u my-app -f           # Follow logs
journalctl -u my-app --since "1 hour ago"
Enter fullscreen mode Exit fullscreen mode

My Top 10 Most Used

# Based on actual history analysis:
history | awk '{$1=""}1' | sort | uniq -c | sort -nr | head -10

# My personal top 10:
# 1. cd          — obvious
# 2. ls -la      — always need details
# 3. git status  — where am I?
# 4. cat         — quick peek
# 5. vim/nano    — edit config
# 6. grep -r     — find things
# 7. ps aux      — what's running?
# 8. df -h       — disk space panic
# 9. systemctl   — manage services
# 10. tail -f    — watch logs
Enter fullscreen mode Exit fullscreen mode

What's YOUR most-used Linux command?

Follow @armorbreak for more devops content.

Top comments (0)