DEV Community

Alex Chen
Alex Chen

Posted on

30 Linux Commands I Use Every Day on My VPS

30 Linux Commands I Use Every Day on My VPS

Running a server means living in the terminal. These are my go-to commands.

File Operations

# Find files by name
find /var/log -name "*.log" -mtime -7        # Modified in last 7 days

# Find large files (disk space cleanup!)
du -h --max-depth=2 / | sort -hr | head -20   # Top 20 largest directories

# Quick file search (faster than find)
locate nginx.conf                              # Needs updatedb first

# Watch a file for changes (logs!)
tail -f /var/log/nginx/error.log               # Follow log in real-time
tail -f /var/log/nginx/access.log | grep "500" # Filter while following

# Search inside files
grep -r "TODO" ./src/                          # Recursive search
grep -rn "error" ./src/                        # With line numbers
grep -rn "error" ./src/ --include="*.js"       # Only JS files
Enter fullscreen mode Exit fullscreen mode

Process Management

# What's running?
ps aux                                        # All processes
ps aux | grep node                            # Filter processes

# Real-time process monitor
top                                           # Interactive, press q to quit
htop                                          # Better top (colorful)

# Kill processes
kill 12345                                    # Graceful kill (PID)
kill -9 12345                                 # Force kill
pkill -f "node server.js"                     # Kill by name pattern
killall node                                  # Kill all node processes

# Find what's using a port
lsof -i :3000                                 # Who's using port 3000?
ss -tlnp | grep :3000                         # Alternative (faster)

# Background & foreground
node server.js &                               # Run in background
jobs                                           # List background jobs
fg %1                                          # Bring job 1 to foreground
nohup node server.js > app.log 2>&1 &          # Survives logout
Enter fullscreen mode Exit fullscreen mode

Network

# Test connectivity
curl -I https://example.com                   # Headers only
curl -s https://api.example.com/data | jq .    # Pretty-print JSON response
wget -qO- http://example.com                   # Download to stdout

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

# Port check
nc -zv google.com 443                          # Is port 443 open?

# Network info
ip addr show                                   # Your IPs and interfaces
curl ifconfig.me                               # Public IP address
Enter fullscreen mode Exit fullscreen mode

Disk & Memory

# Disk usage
df -h                                          # Human-readable disk usage
du -sh *                                       # Directory sizes in current folder

# Memory usage
free -h                                         # RAM usage
cat /proc/meminfo                              # Detailed memory info

# System resources overview
vmstat 1                                       # Update every second
iostat 1                                       # Disk I/O stats
Enter fullscreen mode Exit fullscreen mode

Text Processing

# View files
less bigfile.log                               # Scrollable viewer (q to quit)
head -n 50 file.log                            # First 50 lines
tail -n 50 file.log                            # Last 50 lines

# Count things
wc -l file.txt                                 # Line count
wc -w file.txt                                 # Word count
wc -c file.txt                                 # Character count

# Sort & unique
sort names.txt                                  # Alphabetical sort
sort -n numbers.txt                             # Numerical sort
sort -k2 -t',' data.csv                         # Sort by column 2
uniq -c sorted.txt                             # Count duplicates

# Extract columns
cut -d',' -f1,3 data.csv                       # Columns 1 and 3
awk -F',' '{print $1, $3}' data.csv            # Same with awk

# Search & replace in files
sed -i 's/old/new/g' file.txt                 # In-place replace all occurrences
sed -i 's/port 8080/port 3000/g' nginx.conf    # Change port number
Enter fullscreen mode Exit fullscreen mode

Permissions

# Check permissions
ls -la                                         # Long format with permissions

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

# Change permissions
chmod 755 script.sh                            # rwxr-xr-x
chmod +x script.sh                             # Make executable
chmod -R 755 /var/www/html                     # Recursively

# Common permission patterns:
# 644 = rw-r--r-- (files)
# 755 = rwxr-xr-x (scripts/directories)
# 700 = rwx------ (private)
# 777 = rwxrwxrwx (avoid this!)
Enter fullscreen mode Exit fullscreen mode

Compression & Archives

# tar.gz (most common)
tar -czvf archive.tar.gz folder/              # Create
tar -xzvf archive.tar.gz                       # Extract
tar -tzvf archive.tar.gz                       # List contents

# zip
zip -r archive.zip folder/                    # Create
unzip archive.zip                              # Extract

# Quick single-file compression
gzip file.txt → file.txt.gz                   # Compress
gunzip file.txt.gz                            # Decompress
Enter fullscreen mode Exit fullscreen mode

SSH & Remote

# Connect
ssh user@server.com                            # Basic connection
ssh -p 2222 user@server.com                    # Custom port

# Copy files
scp file.txt user@server.com:/path/to/         # Upload
scp user@server.com:/path/to/file.txt ./      # Download
scp -r folder/ user@server.com:/path/to/      # Upload directory

# Key-based auth (no password!)
ssh-keygen -t ed25519                          # Generate key
ssh-copy-id user@server.com                    # Copy key to server

# Config file (~/.ssh/config) — save typing!
Host myserver
    HostName 192.168.1.100
    User ubuntu
    IdentityFile ~/.ssh/id_ed25519
    Port 2222

# Now just: ssh myserver
Enter fullscreen mode Exit fullscreen mode

Systemd Services

# Manage services
sudo systemctl start nginx                     # Start service
sudo systemctl stop nginx                      # Stop
sudo systemctl restart nginx                  # Restart
sudo systemctl status nginx                   # Check status
sudo systemctl enable nginx                   # Start on boot
sudo systemctl disable nginx                  # Don't start on boot

# Journal logs
journalctl -u nginx                           # Service logs
journalctl -u nginx -f                        # Follow logs
journalctl --since "2026-01-15"              # Logs since date
journalctl -u nginx --since "1 hour ago"     # Last hour
Enter fullscreen mode Exit fullscreen mode

Aliases I Can't Live Without

# Add to ~/.bashrc or ~/.zshrc
alias ll='ls -alF'           # Better ls
alias la='ls -A'             # Hidden files too
alias ..='cd ..'             # Go up one level
alias ...='cd ../..'         # Up two levels
alias grep='grep --color=auto'  # Colored output
alias df='df -h'             # Human-readable
alias du='du -h'             # Human-readable
alias ports='ss -tlnp'       # Listening ports
alias myip='curl ifconfig.me' # Public IP
alias weather='curl wttr.in'  # Weather in terminal
alias cls='clear'            # Clear screen
alias gs='git status'        # Git status
alias gp='git push'          # Git push
alias gl='git log --oneline -10' # Recent commits
Enter fullscreen mode Exit fullscreen mode

What's your most-used Linux command? Did I miss any essentials?

Follow @armorbreak for more sysadmin content.

Top comments (0)