Stop new users from spawning shell processes that linger forever

User & Group Management

Stop new users from spawning shell processes that linger forever

🧩 The Challenge

You finally lock down user permissions, but then you realize that every time someone logs in and kicks off a background script, that process hangs around even after they disconnect. It’s a total mess of orphaned background tasks eating up your CPU.

💡 The Fix

Just tweak the login definition files to kill off processes when the session closes. You’ll save your server from turning into a graveyard of abandoned sub-processes.

echo "KillUserProcesses=yes" >> /etc/systemd/logind.conf && systemctl restart systemd-logind

⚙️ Why It Works

This setting forces systemd to track every process started during a user session via cgroups and terminates them automatically once the last session closes. Without this, your users are essentially running permanent background daemons without you knowing it.

🚀 Pro-Tip: Check your existing stray processes first with loginctl session-status to see who is hiding what.

Linux Tips & Tricks | © ngelinux.com | 8/12/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted