Stop users from lingering in a group you just booted them from

User & Group Management

Stop users from lingering in a group you just booted them from

🧩 The Challenge

You finally drag that one dev out of the sudoers group, but they stay logged in and keep running commands with elevated privileges like nothing happened. It’s frustrating as hell when you think you’ve locked something down only to realize the session is still active.

💡 The Fix

Don’t settle for just editing /etc/group because that doesn’t touch existing processes. You have to kill their active login sessions to force a refresh of their credentials.

loginctl terminate-user username

⚙️ Why It Works

Sessions in modern Linux rely on systemd-logind to track user state, so sending a termination signal here cleans up every process that user owns across all their open sessions. It’s way more effective than hunting down PIDs manually and hoping you don’t miss a background job.

🚀 Pro-Tip: Run loginctl list-users first if you need to double-check which session ID is acting up before nuking the whole user context.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted