Site icon New Generation Enterprise Linux

Force logout of a user session without nuking their account

User & Group Management

Force logout of a user session without nuking their account

đź§© The Challenge

Dealing with a compromised account or a runaway process that just won’t die is annoying enough, but trying to kill a user’s entire session cleanly is usually a nightmare. I’ve wasted way too much time hunting down orphan processes after a simple pkill.

đź’ˇ The Fix

Instead of manually finding and murdering every PID, you can use loginctl to send a kill signal to the entire user session. It’s cleaner, safer, and saves you from those persistent background tasks that usually stick around.

loginctl terminate-user <username>

⚙️ Why It Works

This utility talks directly to systemd-loginst, which tracks every process spawned in that user’s session scope and sends a SIGTERM followed by a SIGKILL to every single one of them. It ensures nothing stays running under that UID.

🚀 Pro-Tip: Use loginctl list-sessions first if you need to be surgical and only kick them off one specific TTY or SSH connection.

Linux Tips & Tricks | © ngelinux.com | 9/16/2026

0 0 votes
Article Rating
Exit mobile version