Back to lessons

Hosting Operations

Print Runtime Paths and User From systemd

A service failure points at credentials or paths, and you need systemd's resolved unit properties without reading multiple files manually.

Command

systemctl show app-worker --property=FragmentPath,DropInPaths,EnvironmentFiles,ExecStart,User,WorkingDirectory --no-pager

What changed

Nothing changes. systemctl prints selected runtime configuration properties.

Danger

safe

When to use it

Use when a service fails at USER, CHDIR, EXEC, environment-file loading, or after a deploy that changed paths.

When not to use it

Do not assume these values prove the files exist or permissions are correct; follow up with ls, stat, getent, or namei as needed.

Undo or recovery

No undo needed because the command is read-only.

Expected output

Selected unit properties showing fragment paths, drop-ins, environment files, ExecStart, User, and WorkingDirectory.

demo script

Disposable terminal steps

  1. systemctl status app-worker --no-pager --lines=50
  2. systemctl show app-worker --property=FragmentPath,DropInPaths,EnvironmentFiles,ExecStart,User,WorkingDirectory --no-pager

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ systemctl status app-worker --no-pager --lines=50
● app-worker.service - Background job worker
     Loaded: loaded (/etc/systemd/system/app-worker.service; enabled; preset: enabled)
    Drop-In: /etc/systemd/system/app-worker.service.d
             └─override.conf
     Active: failed (Result: exit-code) since Thu 2026-06-25 14:22:17 CDT; 4min ago
   Duration: 1.243s
    Process: 2144 ExecStart=/srv/app/bin/worker --queue default (code=exited, status=217/USER)
   Main PID: 2144 (code=exited, status=217/USER)
        CPU: 38ms

Jun 25 14:22:17 vps systemd[1]: Started app-worker.service - Background job worker.
Jun 25 14:22:17 vps systemd[2144]: app-worker.service: Failed to determine user credentials: No such process
Jun 25 14:22:17 vps systemd[2144]: app-worker.service: Failed at step USER spawning /srv/app/bin/worker: No such process
Jun 25 14:22:17 vps systemd[1]: app-worker.service: Main process exited, code=exited, status=217/USER
Jun 25 14:22:17 vps systemd[1]: app-worker.service: Failed with result 'exit-code'.
::exit-code::0
$ systemctl show app-worker --property=FragmentPath,DropInPaths,EnvironmentFiles,ExecStart,User,WorkingDirectory --no-pager
FragmentPath=/etc/systemd/system/app-worker.service
DropInPaths=/etc/systemd/system/app-worker.service.d/override.conf
EnvironmentFiles=/etc/app/worker.env (ignore_errors=no)
ExecStart={ path=/srv/app/bin/worker ; argv[]=/srv/app/bin/worker --queue default ; ignore_errors=no ; start_time=[Thu 2026-06-25 14:22:17 CDT] ; stop_time=[Thu 2026-06-25 14:22:17 CDT] ; pid=2144 ; code=exited ; status=217 }
User=missing-appuser
WorkingDirectory=/srv/app/current
::exit-code::0

YouTube Short

Ask systemd what it will run.

When a service fails on user or path setup, print the resolved properties. It shows the user, working directory, env files, and command.

LinkedIn hook

Confirm the user, working directory, env file, and ExecStart systemd is actually using.

Question: When a service fails at USER, EXEC, or CHDIR, which property do you check first?

experiments

A/B tests to run

Metric: save_rate

A: Ask systemd what it will run.

B: Print resolved paths and user.