Source: Dev.to | Jan 19, 2026 (UTC)
When working with systemd, it is common to rely on network-online.target to ensure services start only after the network is fully up. However, this target exists at the system level, while many modern workflows run long-lived services in the user systemd instance (for example, user-managed daemons, development tooling, or per-user agents). This setup provides a clean bridge: when the system reaches “network online,” it triggers a corresponding marker target inside a specific user’s systemd instance—automatically and reliably at boot.
The solution consists of three parts:
- A small installation script (
install.sh) that sets up required system and user units. - A user-level marker unit (
network-online.target) that exists only to represent “network online” inside the user instance. - A system-level templated service (
[email protected]) that waits for system networking to be online and then starts the user-level target for a given user ID (UID).
Together, these components ensure that user services can depend on network-online.target in the user instance, even though the real network readiness signal originates at the system level.
Enabling User systemd Without an Active Login
A key challenge with user systemd instances is lifecycle: by default, they are tied to interactive logins. If the user is not logged in, the user systemd instance may not exist, which prevents user services from starting at boot.
The installation script addresses this by enabling linger:
loginctl enable-linger $USER
With linger enabled, the user’s systemd instance can run even when no session is active. This is a prerequisite for starting user services during the boot process.
Creating a User-Level Network-Online Marker
In the user systemd directory (~/.config/systemd/user), the setup installs a minimal network-online.target unit:
[Unit] Description=User-level Network is Online (marker only) Documentation=man:systemd.special(7)
Enter fullscreen mode
Exit fullscreen mode


Залишити відповідь