Cheatsheet: Linux CLI, Systemd & Networking
| Task |
Command |
| Print current directory |
pwd |
| List all files with human-readable sizes |
ls -lah |
| Create nested directories safely |
mkdir -p ~/app/logs ~/app/config |
| Find files by name |
find /etc -type f -name "*.conf" |
Make script executable (rwxr-xr-x) |
chmod 755 script.sh |
Lock down .env or SSH private keys |
chmod 600 .env |
| Change ownership recursively |
sudo chown -R user:group /opt/app |
| Task |
Command |
| Follow live log output |
tail -f /var/log/nginx/error.log |
| Case-insensitive search with line numbers |
grep -ni "error" app.log |
Check available RAM (available column) |
free -h |
| Check disk space per mount |
df -h |
| Find largest subdirectories |
sudo du -h --max-depth=1 /var | sort -hr |
| Manage systemd service |
sudo systemctl status | start | reload | enable --now <svc> |
| Inspect service logs via journald |
sudo journalctl -u ssh -n 50 --no-pager |
| Reload systemd after editing unit files |
sudo systemctl daemon-reload |
| Task |
Command |
| Show interfaces and IP addresses |
ip -br a |
| List listening TCP/UDP ports & processes |
sudo ss -tulnp |
Query DNS A record directly via 1.1.1.1 |
dig @1.1.1.1 wiki.laptc.cloud A +noall +answer |
| Inspect HTTP/HTTPS response headers |
curl -I https://wiki.laptc.cloud/ |
| Generate Ed25519 SSH key pair |
ssh-keygen -t ed25519 -C "laptop" |
| Open secure SSH local tunnel |
ssh -N -L 8080:127.0.0.1:8080 my-vps |
Allow SSH, HTTP, HTTPS and enable ufw |
sudo ufw allow OpenSSH && sudo ufw allow 80,443/tcp && sudo ufw enable |
LapTC Wiki · wiki.laptc.cloud · Self-hosted with Astro Starlight, Docker, Nginx & Caddy