Create and Harden a Custom systemd Service

A supplied application needs to run as a service under its own account, with a controlled environment, an automatic restart, and a filesystem sandbox that lets it write to one place and nothing else.

Skill labintermediate~45 minPro

What you'll do

  • ✓Create a system account and a state directory for a service
  • ✓Write a unit with User, WorkingDirectory, ExecStart, EnvironmentFile and Restart
  • ✓Add NoNewPrivileges, PrivateTmp, ProtectSystem=strict and ReadWritePaths without breaking the app
  • ✓Verify with systemd-analyze, prove the sandbox from the service account, and watch it recover from a crash

Lab outline

  1. 01Identity
  2. 02The unit
  3. 03Harden

Before you start

  • Delegate a Narrowly Scoped sudo Action
  • Operate systemd Services

Every lab runs on a real machine of your own in the browser — no installs, nothing to clean up — and checks your work automatically as you go.

← All Linux System Administration labs

Your first machine is
8 seconds away.

Learn by doing on real machines — and give every AI agent one of its own.

Free forever · No credit card · Cancel anytime

Create and Harden a Custom systemd Service — Linux lab | Kube Labs