Site icon New Generation Enterprise Linux

Stop user sessions from holding onto dead locks

User & Group Management

Stop user sessions from holding onto dead locks

đź§© The Challenge

Ever tried to delete a user account only to get slapped with a “user is currently used by process” error? It’s a total pain when you’re trying to clean up after a contractor who left weeks ago and somehow still has a stray cron job running in the background.

đź’ˇ The Fix

Use the loginctl tool to effectively kick anyone off the system before you try removing their UID, which saves you from hunting down random zombie processes.

loginctl terminate-user username
&& userdel -r username

⚙️ Why It Works

This command tells systemd to send a SIGTERM to every process owned by that user session, cleaning up the environment cleanly instead of just killing things blindly.

🚀 Pro-Tip: Always double check the user’s running processes with pgrep -u username first if you aren’t sure what’s actually under their hood.

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

0 0 votes
Article Rating
Exit mobile version