Tags: linux, ubuntu, systemd, permissions, cron, journalctl, networking, devops Last updated: 2026-06-26

Linux Server (Ubuntu) Cheatsheet

Quick Reference

CommandDescription
systemctl status svcService status
journalctl -u svc -fFollow service logs
chmod 755 fileSet permissions
chown user:group fileChange owner
crontab -eEdit cron jobs
ss -tlnpList listening ports
ufw statusFirewall status
ip addrShow IP addresses
df -hDisk 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