Writing a Systemd Service File

This is how to start a program automatically when a Linux system boots up. Modern Linuxes use systemd to manage startup programs (it does other things too).

The latest thing I wrote a service file for was automuteus, a Discord bot for Among Us. The definition is pretty simple:

[Unit]
Description=Among Us Discord bot
Wants=network.target
After=network.target

[Service]
User=amongusbot
Group=amongusbot
# automuteus shuts down gracefully when receiving the SIGINT signal (ctrl+c on a keyboard).
# It shuts down 5 seconds after receiving the signal.
KillSignal=SIGINT

ProtectSystem=full
ReadWritePaths=/opt/amongusbot
WorkingDirectory=/opt/amongusbot
ExecStart=/opt/amongusbot/amongusbot
Environment="HOST=http://example.com:8123"

[Install]
WantedBy=multi-user.target

User Tools