Skip to content

Instantly share code, notes, and snippets.

@sergeyklay
Forked from chrj/template.service
Created July 14, 2019 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergeyklay/b364e4a7e4f4311c3b47ae55ee770530 to your computer and use it in GitHub Desktop.
Save sergeyklay/b364e4a7e4f4311c3b47ae55ee770530 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