Sunshine can run as a systemd service on Linux, providing automatic startup, process management, and logging integration. Two service types are available:
sunshine.service - Unprivileged service for XDG Portal or X11 capture
sunshine-kms.service - Privileged service for KMS (Kernel Mode Setting) capture
After installing Sunshine, verify the service files exist:
3
# User service filesls -l ~/.config/systemd/user/sunshine*.service# Or system service files (if installed system-wide)ls -l /usr/lib/systemd/user/sunshine*.service
[Unit]Description=Sunshine - Self-hosted game stream host for MoonlightStartLimitIntervalSec=500StartLimitBurst=5Conflicts=sunshine-kms.serviceAfter=graphical-session.target xdg-desktop-autostart.target xdg-desktop-portal.service[Service]# Avoid starting Sunshine before the desktop is fully initializedExecStartPre=/bin/sleep 5ExecStart=/usr/bin/sunshineRestart=on-failureRestartSec=5sNoNewPrivileges=true[Install]WantedBy=graphical-session.target
[Unit]Description=Sunshine - Self-hosted game stream host for Moonlight (KMS)StartLimitIntervalSec=500StartLimitBurst=5Conflicts=sunshine.serviceAfter=graphical-session.target xdg-desktop-autostart.target[Service]# Avoid starting Sunshine before the desktop is fully initializedExecStartPre=/bin/sleep 5ExecStart=/usr/bin/sunshineRestart=on-failureRestartSec=5s[Install]WantedBy=graphical-session.target
# Add to input group (for gamepad/keyboard/mouse)sudo usermod -aG input $USER# Add to video group (for GPU access)sudo usermod -aG video $USER# Add to audio group (for audio capture)sudo usermod -aG audio $USER# Log out and back in for changes to take effect
[Service]# Memory limitMemoryMax=2GMemoryHigh=1.5G# CPU quota (80% of one core)CPUQuota=80%# Process limitsTasksMax=100# File descriptor limitLimitNOFILE=4096
[Unit]# Start after these servicesAfter=graphical-session.targetAfter=network-online.targetAfter=pulseaudio.service# Require these servicesRequires=network-online.target# Stop if these services stopBindsTo=graphical-session.target
For system-level installation (not recommended for most users):
# Create system service filesudo nano /etc/systemd/system/sunshine.service
[Unit]Description=Sunshine Game StreamingAfter=network-online.targetWants=network-online.target[Service]Type=simpleUser=sunshineGroup=sunshineExecStart=/usr/bin/sunshineRestart=on-failureRestartSec=5s[Install]WantedBy=multi-user.target