Stop fighting with stale SSH sessions when you change a user shell
User & Group Management
Stop fighting with stale SSH sessions when you change a user shell
🧩 The Challenge
Ever updated a user’s login shell in /etc/passwd only to have them complain that their environment is still totally broken or they can’t even get in? It turns out that some sessions just don’t want to let go of the old shell until you force their hand.
💡 The Fix
Use loginctl to kill off the user’s lingering processes so the next login actually picks up the changes you just made to their account settings.
loginctl terminate-user <username>
⚙️ Why It Works
Systemd keeps a tight grip on user sessions via its user manager, so even if you fix the shell file, the existing session manager keeps the old environment alive until the process tree is nuked.
🚀 Pro-Tip: Run loginctl list-users first to make sure you aren’t about to nuke the wrong person and cause a production outage.
Linux Tips & Tricks | © ngelinux.com | 8/25/2026
