Stop your user accounts from lingering in the shadows after they quit

User & Group Management

Stop your user accounts from lingering in the shadows after they quit

🧩 The Challenge

Dealing with a pile of inactive accounts on a shared dev box is a nightmare, especially when you’re not sure if they actually left or just went on a long vacation. I’ve wasted way too much time auditing home directories for someone who hasn’t logged in since the Eisenhower administration.

💡 The Fix

Use the lastlog command to pull a clean list of folks who haven’t touched the system in months so you can lock or nuke their accounts with confidence. It saves you from accidentally deleting a guy who just happens to be on a two-month sabbatical.

lastlog -b 90 | grep -v "Never logged in" | awk '{print $1}'

⚙️ Why It Works

This command grabs the lastlog database and filters for anyone who hasn’t authenticated within the last 90 days. But watch out, you’ll need to manually exclude system accounts like bin or daemon before you go on a rampage.

🚀 Pro-Tip: Pipe that output into a loop to run usermod -L and lock them all in one go before you permanently delete anything.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted