Skip to content

Instantly share code, notes, and snippets.

@chrj
Created May 4, 2018 14:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrj/47a1e66bad15a25d7aa3e89fbc507c9b to your computer and use it in GitHub Desktop.
Save chrj/47a1e66bad15a25d7aa3e89fbc507c9b to your computer and use it in GitHub Desktop.
Sample service unit file for systemd
[Unit]
Description=My service
[Service]
ExecStart=/usr/local/bin/my-service \
-argument value \
-otherargument othervalue
# Setuid/Setgid
User=nobody
Group=nogroup
# Create a private tmp and device dir for this process
PrivateTmp=true
PrivateDevices=true
# Mount system and home directories read-only
ProtectSystem=full
ProtectHome=read-only
# if privileged ports are needed
# CapabilityBoundingSet=CAP_NET_BIND_SERVICE
# Any need environment variables
# Environment='KEY=value'
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment