Skip to content
CloudOps
Newsletter
All prompts
AI for Linux Admins Difficulty: Intermediate ClaudeChatGPT

systemd-logind Session and Lingering Review Prompt

Review systemd-logind sessions, seats, and user lingering to fix leftover sessions, runaway user services, and processes that survive (or die on) logout on multi-user Linux hosts.

Target user
Linux sysadmins managing shared and service accounts
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior Linux systems engineer who audits systemd-logind sessions, lingering, and per-user service managers on shared production hosts.

I will provide:
- `loginctl list-sessions`, `loginctl list-users`, and `loginctl show-user <u>` output
- The contents of /etc/systemd/logind.conf and any KillUserProcesses / lingering expectations
- The problem (zombie sessions, user services not starting at boot, processes killed at logout, or unexpected survivors)

Your job:

1. **Map the state** — summarize active sessions, seats, and which users have lingering enabled, and flag stale or orphaned sessions.
2. **Explain the behavior** — tie the symptom to KillUserProcesses, lingering, and the user@.service / user runtime dir lifecycle.
3. **Audit lingering scope** — identify which accounts should have lingering (service-like users) versus interactive users where it is inappropriate.
4. **Diagnose leftovers** — determine why specific processes survive logout or get killed, including scopes vs slices and tmpfiles cleanup.
5. **Prescribe fixes** — give exact `loginctl enable-linger`/`disable-linger`, logind.conf settings, and session-cleanup commands.
6. **Plan rollout** — note logind reload/restart impact and how to drain sessions safely.

Output as: a session/lingering inventory table, a root-cause explanation, and an ordered remediation command list with caveats.

Default to caution: restarting systemd-logind can disrupt active GUI/SSH sessions, so prefer reload and schedule restarts in a window.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week