← Cheatsheets
Tags: linux, ubuntu, systemd, permissions, cron, journalctl,
networking, devops
Last updated: 2026-06-26
Linux Server (Ubuntu) Cheatsheet
Quick Reference
| Command | Description |
systemctl status svc | Service status |
journalctl -u svc -f | Follow service logs |
chmod 755 file | Set permissions |
chown user:group file | Change owner |
crontab -e | Edit cron jobs |
ss -tlnp | List listening ports |
ufw status | Firewall status |
ip addr | Show IP addresses |
df -h | Disk usage |
systemd
# Service unit: /etc/systemd/system/myapp.service
[Unit]
Description=My App
After=network.target
[Service]
Type=simple
User=app
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/node server.js
Restart=always
RestartSec=5
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
systemctl start|stop|restart|reload myapp
systemctl enable|disable myapp
systemctl status myapp
systemctl daemon-reload # After editing units
systemctl list-units --state=failed
File Permissions
chmod 755 script.sh # rwxr-xr-x
chmod 644 file.txt # rw-r--r--
chmod 600 secret.key # rw-------
chmod u+x script.sh # Add execute for user
chown user:group file.txt
chown -R app:app /opt/myapp
cron Jobs
crontab -e # Edit
crontab -l # List
# Every hour
0 * * * * /opt/backup.sh
# Daily at 2:30 AM
30 2 * * * /usr/bin/certbot renew
# Every 15 minutes
*/15 * * * * /opt/healthcheck.sh >> /var/log/hc.log 2>&1
journalctl
journalctl -u myapp -f # Follow
journalctl -u myapp --since "1 hour ago"
journalctl -b # Current boot
journalctl -p err # Errors only
journalctl --disk-usage
journalctl --vacuum-size=500M
Network Troubleshooting
ip addr show
ss -tlnp # Listening TCP
ss -s # Summary
dig vibed.win
ping -c 4 google.com
curl -I https://vibed.win
nc -zv example.com 443 # Check port open
ufw allow 22/tcp
ufw allow 80,443/tcp
ufw enable
apt Package Management
apt update && apt upgrade
apt install nginx
apt remove nginx # Keep config
apt purge nginx # Remove + config
apt autoremove
Tips
- Use
systemctl daemon-reload after
editing unit files.
- Set
Restart=always and
RestartSec=5 in production units.
- Prefer systemd timers over cron for services
needing dependency tracking.