——
MediumINCIDENTS

A systemd service appeared that nobody remembers installing

A practical incident workflow for preserving evidence, deciding containment and recovering safely when an unfamiliar systemd service appears on an authorised Linux host.

A practical incident workflow for preserving evidence, deciding containment and recovering safely when an unfamiliar systemd service appears on an authorised Linux host.

systemdLinux incident responsepersistenceevidence preservation

Summary

Status: Reported — this is a containment and evidence-preservation workflow for an unexplained service, not proof of compromise.
Audience: Linux administrators handling a server they own or are authorised to investigate.
Published: 6 November 2026 · Updated: 5 November 2026 · Practical time: 45–75 minutes · Reviewer: notmyfault.fail Research

A service unit that nobody recognises deserves investigation, but deleting it first can destroy the timeline and leave a running process behind. This incident workflow preserves volatile evidence, separates observation from containment, and gives a defensible route to recovery.

Status and confidence

An unfamiliar unit may be legitimate: a package upgrade, configuration-management change, vendor agent or a renamed service can create one. Treat the event as reported, not confirmed malicious, until the unit file, execution chain, package ownership and related activity have been reviewed. Escalate the priority when the service runs as root, starts at boot, opens an unexpected listener, launches from a writable directory, or has a credential-bearing environment.

UTC timeline

Record all commands, operator, hostname and UTC timestamps in the incident ticket. Do not rely on local wall-clock time.

  1. T0 — discovery: capture the alert, unit name, host and source of discovery.
  2. T0–15 min — preserve: record service state, unit-file contents, journal and process/network state before changing it.
  3. T0–30 min — decide: an incident lead decides whether containment is justified by active risk.
  4. T0 onwards — recover: rebuild or restore only after scope, credentials and persistence have been assessed.

First response: preserve before changing anything

Do not run systemctl disable --now, delete the unit file, reboot, or run a “cleaner” before evidence collection unless an incident lead decides that immediate harm outweighs lost evidence. Those actions can remove logs, terminate the process tree and change file timestamps.

Work on the authorised host as a privileged responder. Send command output to a protected case directory or approved remote collector; protect it from routine log rotation.

sudo -i
date -u --iso-8601=seconds
hostnamectl
systemctl status suspicious.service --no-pager -l
systemctl show suspicious.service -p Id -p Names -p LoadState -p ActiveState -p SubState -p FragmentPath -p SourcePath -p DropInPaths -p ExecStart -p User -p Group -p MainPID -p Environment --no-pager
systemctl cat suspicious.service

Expected result: FragmentPath identifies the main unit file; DropInPaths reveals overrides; ExecStart, User and MainPID identify what systemd believes it launched. A missing unit or inactive unit is not an all-clear: retain the error and continue with journal and unit-file searches.

Interpretation: a unit under /etc/systemd/system is locally administered; one under a distribution unit directory may still be altered by a package or an override. Location alone does not prove intent.

Build the evidence record

1. Unit, dependency and journal evidence

systemctl list-dependencies --all suspicious.service
systemctl list-unit-files --type=service --no-pager | grep -F 'suspicious'
journalctl -u suspicious.service --since '2026-11-01 00:00:00 UTC' --utc --no-pager -o short-iso
journalctl _SYSTEMD_UNIT=suspicious.service --utc --no-pager -o verbose
find /etc/systemd/system /usr/lib/systemd/system /lib/systemd/system -maxdepth 2 -type f -iname '*suspicious*' -printf '%TY-%Tm-%TdT%TH:%TM:%TSZ %s %p\n' 2>/dev/null

Good result: the journal and unit file align with an approved change record and a known package.
Bad result: first execution follows an unknown login, cron job, installer, or a download into /tmp, /var/tmp, a home directory or another writable path.
Unclear result: journald retention is too short or timestamps conflict; preserve what exists and obtain central logs rather than filling gaps with assumptions.

Use systemd-analyze verify /path/to/unit only as a syntax and dependency check; it does not establish trust.

2. Process tree, executable and network state

pid=$(systemctl show -p MainPID --value suspicious.service)
ps -o pid,ppid,user,lstart,etime,cmd -p "$pid"
pstree -aps "$pid"
readlink -f "/proc/$pid/exe"
tr '\0' ' ' < "/proc/$pid/cmdline"; echo
sudo ss -plant
sudo lsof -nP -p "$pid"
sudo ls -l "/proc/$pid/cwd" "/proc/$pid/exe"

Capture the executable path and its parent process before stopping it. An expected listener must match the service’s documented role and approved change. Do not probe external addresses merely because they appear in a connection list; route any network analysis through the incident process.

3. File metadata, hashes and package ownership

For the unit file and executable, preserve path, ownership, mode, size, timestamps and a cryptographic hash. Hashes identify the exact collected bytes; they do not make a file benign.

unit=$(systemctl show -p FragmentPath --value suspicious.service)
exe=$(readlink -f "/proc/$pid/exe")
stat -c '%n | owner=%U:%G mode=%a size=%s | mtime=%y ctime=%z' "$unit" "$exe"
sha256sum "$unit" "$exe"
dpkg-query -S "$unit" "$exe" 2>/dev/null || true
rpm -qf "$unit" "$exe" 2>/dev/null || true

On Debian/Ubuntu, dpkg-query -S can identify a path owned by an installed package. On RPM-based systems, rpm -qf performs the comparable ownership check. “Not owned by a package” is a lead, not a verdict: locally deployed software and configuration management may be legitimate. Preserve any drop-ins and referenced scripts too.

Containment decision

Decision owner: [incident lead].
Target time: within 30 minutes of confirming active risk.

Contain when the unit is running suspicious code, has unauthorised persistence, exposes a harmful service, or the owner judges that waiting risks wider compromise. Preserve the above evidence first where feasible. If immediate containment cannot wait, record who authorised it, the UTC time and what evidence was necessarily lost.

A reversible containment option is to isolate the host through the approved network-control path, then stop the service without deleting its files:

sudo systemctl stop suspicious.service
sudo systemctl mask suspicious.service
sudo systemctl is-enabled suspicious.service

Impact: masking can break dependent applications and a service that is required for boot or business operations. Confirm dependencies and maintenance ownership first. mask is reversible; it is not eradication.

Rollback: after the incident lead approves restoration and the unit has been validated, run:

sudo systemctl unmask suspicious.service
sudo systemctl daemon-reload
sudo systemctl start suspicious.service
sudo systemctl status suspicious.service --no-pager -l

Do not restart a suspicious service merely to test it. Validate in a rebuilt or isolated environment where practical.

Credentials and session assumptions

Assume credentials exposed to the service process may need rotation: service-account secrets, API tokens, SSH keys, cloud instance credentials and application database passwords. Review Environment=, environment files, mounted secret paths, deployment tooling and access logs without copying secret values into tickets. Invalidate active sessions according to the identity provider and application procedures. The scope decision belongs to [incident lead] with [identity owner] and [application owner].

Eradication, recovery and closure

Owner: [platform owner]; target: after scope approval.

A clean rebuild is preferred when execution provenance cannot be established, root-level compromise is plausible, kernel or boot-chain integrity is in doubt, or additional persistence is found. Restore application data only from known-good backups after scanning and validating it. A targeted repair can be appropriate only when package provenance, the change record and the full execution chain prove a benign cause.

Before closure, verify all of the following:

  • the replacement host is patched, monitored and enrolled in configuration management;
  • no unknown unit, timer, cron entry, SSH key, user, container or startup script remains;
  • expected services, health checks and log forwarding work;
  • credentials and sessions in scope were rotated or formally accepted as an exception;
  • the incident record includes hashes, timestamps, command output, containment authority and recovery evidence.
  • Linux audit logs that are useful during an incident: journald, auditd and remote retention — use durable logging to improve future evidence.
  • A Linux server may be compromised — use the broader triage process when the service is only one sign of compromise.
  • Unknown script incident — apply the same preserve-before-change principle to ad-hoc execution.

Change log

  • 2026-11-05: Initial draft. No previous claims corrected.

References

  1. systemd, “systemctl” manual: https://www.freedesktop.org/software/systemd/man/latest/systemctl.html (accessed 5 November 2026).
  2. systemd, “systemd.service” manual: https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html (accessed 5 November 2026).
  3. systemd, “journalctl” manual: https://www.freedesktop.org/software/systemd/man/latest/journalctl.html (accessed 5 November 2026).
  4. Debian manpages, “dpkg-query”: https://manpages.debian.org/dpkg-query (accessed 5 November 2026).
  5. Red Hat Enterprise Linux documentation, “Managing systemd”: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/configuring_basic_system_settings/assembly_managing-systemd_configuring-basic-system-settings (accessed 5 November 2026).