Cheat Sheet
Linux Server Cheat Sheet
Essential commands for server administration — files, permissions, processes, SSH, and monitoring
File Operations
ls -lah # List files with sizes
du -sh * # Directory sizes
df -h # Disk usage
find . -name "*.log" # Find files
find / -size +100M # Find large files
tree -L 2 # Directory tree (limit 2 levels)
rsync -avz src/ dst/ # Sync directories
Permissions
chmod 644 file # rw-r--r-- (files)
chmod 755 dir # rwxr-xr-x (directories)
chown user:group file # Change owner
chmod +x script.sh # Make executable
umask 022 # Default: 755 dirs, 644 files
Processes
ps aux # All processes
ps aux | grep nginx # Find specific process
top / htop # Interactive process viewer
kill -9 PID # Force kill
kill -15 PID # Graceful kill (SIGTERM)
pkill -f "name" # Kill by name
nohup cmd & # Run immune to hangups
System Info
uname -a # Kernel info
cat /etc/os-release # OS version
free -h # RAM usage
uptime # How long running
lscpu # CPU info
nvidia-smi # GPU status
lspci # PCI devices
lsblk # Block devices
SSH
ssh user@host # Connect
ssh -p 2222 user@host # Custom port
ssh -i key.pem user@host # Key-based auth
ssh -L 8080:localhost:80 host # Port forward
ssh -J jump@host user@target # Jump host
scp file user@host:/path/ # Copy file
ssh-keygen -t ed25519 # Generate key
Networking
curl -I https://example.com # HTTP headers
curl -s ifconfig.me # Public IP
ping -c 4 host # Test connectivity
traceroute host # Route tracing
ss -tulpn # Listening ports
netstat -tulpn # (older) Listening ports
nc -zv host 80 # Test port
Logs
journalctl -u nginx -f # Service logs (follow)
journalctl -u nginx --since "1h" # Last hour
tail -f /var/log/nginx/access.log # Follow file
grep "error" /var/log/syslog # Search logs
dmesg | tail # Kernel messages
Cron
crontab -e # Edit crontab
crontab -l # List cron jobs
# Format: minute hour day month weekday command
0 3 * /opt/backup.sh # Daily 3am
/15 * /opt/check.sh # Every 15 min
@daily /opt/cleanup.sh # Daily
@reboot /opt/start-service.sh # On boot
Screen / Tmux
screen -S session_name # Start named session
screen -ls # List sessions
screen -r session_name # Reattach
Ctrl+A, D # Detach
tmux new -s name # New session
tmux ls # List sessions
tmux attach -t name # Reattach
Ctrl+B, d # Detach