A Systemd Unit is a configuration file that tells systemd on Linux how to start and manage a service, timer, socket or resource. Attackers add or alter units to gain persistence, since they can run code at boot or on a schedule. Defenders should monitor unit directories such as /etc/systemd/system for new or changed files and review ExecStart commands.
What a Systemd Unit Does
A systemd unit is the control point that tells Linux how to launch, supervise, stop, and sometimes schedule a service or other resource. Because units can define startup behaviour, dependencies, and command execution, they are part of the operating-system trust boundary rather than simple configuration text.
For defenders, the key point is that a unit is executable intent. A small change to a unit file can redirect a service binary, add arguments, alter timing, or trigger code at boot, which makes unit integrity central to both hardening and incident response.
Why Unit Files Matter for Persistence and Control
Attackers value systemd units because they can create durable execution paths that survive logoff, reboot, and normal user activity. That makes units especially useful for persistence, scheduled execution, and service manipulation, particularly when they can write to privileged locations or replace an existing service definition.
Units also matter in legitimate administration because they determine dependency order, environment variables, working directories, resource limits, and restart behaviour. In practice, a unit file is often the difference between a service that starts cleanly and one that is noisy, fragile, or unexpectedly exposed.
For readers looking at Linux persistence more broadly, the surrounding techniques are covered in the Linux Persistence Forensics Guide, which places systemd units alongside cron, drop-ins, SSH keys, and other startup mechanisms.
Where to Look When Reviewing Exposure
Exposure usually begins with inventory and path awareness. Common review points include /etc/systemd/system, vendor unit locations, user unit directories, and any drop-in override paths that can change behaviour without replacing the base service file.
The next question is whether the unit is meant to exist, whether its ownership and permissions are sane, and whether its execution commands match the service it claims to represent. A suspicious unit often stands out through a new name, an unexpected drop-in, a changed ExecStart value, or a service file that points at unusual binaries or scripts.
This is also where baseline comparison helps. Differential review of startup locations is the cleanest way to spot unauthorised changes, and the D3-SICA System Init Config Analysis guide is a useful companion for understanding how to baseline and compare system initialisation configuration.
Monitoring, Hardening, and Response
Monitoring should focus on creation, modification, and replacement of unit files, plus the commands they execute. That includes watching for edits in standard unit directories, unexpected use of drop-ins, and service definitions that suddenly reference shells, downloaders, or other nonstandard launch paths.
Hardening is largely about reducing who can alter startup configuration and ensuring that service definitions are owned, readable, and change-controlled in a predictable way. File permission discipline matters here because a writable unit path or override location can turn an administrative convenience into a persistence mechanism.
The M1022 Restrict File and Directory Permissions guide maps directly to that control problem, especially where unit files, drop-ins, and adjacent startup artefacts need tighter access.
If a unit has been altered maliciously, response should include removing the change, checking dependent services, and reviewing whether the same actor modified other startup locations. Treat the unit as a persistence artefact, not just a config file, until the system has been fully reviewed.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
MITRE ATT&CK addresses the attack and risk surface, while CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| MITRE ATT&CK | T1543.002 — Systemd Service | Systemd units are a persistence mechanism used to start services at boot. |
| Recommendation — Hunt for and remove malicious systemd service persistence, then review adjacent startup locations. | ||
| CIS Controls v8 | CIS-5 — Account Management | Systemd unit abuse often depends on excessive local or service control over startup paths. |
| Recommendation — Restrict who can create or modify service startup files and related execution paths. | ||
| NIST SP 800-53 Rev 5 | CM-7 — Least Functionality | Systemd units should only expose the commands and behaviours a service truly needs. |
| CM-6 — Configuration Settings | Unit files are configuration artefacts that require controlled, approved system settings. | |
| SI-4 — System Monitoring | Changes to unit files are a high-value monitoring target for persistence detection. | |
| Recommendation — Disable unnecessary unit behaviour and trim service execution to required functions only. Baseline and enforce approved service unit configuration across hosts. Monitor unit directories and service changes for unauthorised persistence activity. | ||
Related resources from NHI Mgmt Group
- Guide: Linux Privilege Escalation Techniques Guide
- systemd User Unit
- What is the difference between Kubernetes probes and systemd readiness signals?
- What should teams check before switching from systemd to sysvinit in embedded systems?
- How should organisations govern agent identities that belong to a business unit?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org