linux
komovo · website-7c8b549745-qfbjf
Common Linux commands organized by category for quick reference. Commands adapt to your selected distro's init system and package manager.
service management — systemd
bash# view service status
sudo systemctl status nginx -l --no-hostname
# tail logs in real-time
journalctl -u nginx -f --no-hostname
# list all running services
systemctl list-units --type=service --state=running
# restart without blocking
sudo systemctl restart nginx
# enable at boot
sudo systemctl enable --now nginx
disk & filesystem
bash# disk usage summary
df -h
# largest directories
du -sh /* 2>/dev/null | sort -h
# largest files (>100MB)
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k5 -h
# filesystem info
lsblk -f
blkid
# check disk health
sudo smartctl -a /dev/sda
processes & memory
bash# top processes by CPU
top -o %CPU
# top processes by memory
ps aux --sort=-%mem | head -10
# memory overview
free -h
# open file descriptors per process
lsof -n | awk '{{print $1}}' | sort | uniq -c | sort -rn | head -10
# find which process uses a port
ss -tlnp | grep :3000
network
bash# listening ports
ss -tulpn
# active connections
ss -tn state established
# quick network scan
nmap -sn 192.168.1.0/24
# resolve DNS
dig +short google.com
# wireguard status
sudo wg show
# speed test through tunnel
curl --interface wg0 -o /dev/null -s -w '%{speed_download}' \
'https://speed.cloudflare.com/__down?bytes=50000000'
logs & journal
bash# view logs for a service
journalctl -u nginx -f --no-hostname
# last boot logs
journalctl -p err -b --no-hostname
# disk usage by logs
journalctl --disk-usage
# clean up old logs
sudo journalctl --vacuum-time=7d
system info
bash# kernel and architecture
uname -a
# cpu info
lscpu
cat /proc/cpuinfo | grep 'model name' | head -1
# memory
cat /proc/meminfo | grep MemTotal
# pci devices
lspci | grep -E 'VGA|Audio|Network'
# dmesg kernel messages
dmesg | tail -20
# uptime
uptime