Site icon New Generation Enterprise Linux

Stop hunting for locked accounts without checking the shadow file

User & Group Management

Stop hunting for locked accounts without checking the shadow file

🧩 The Challenge

Dealing with a dev who can’t log into a box is always a headache, especially when you start guessing whether it’s a key issue or a locked password. I’ve spent way too long checking /etc/shadow manually like a caveman before realizing there is a better way.

💡 The Fix

Use the status flag on the passwd command to see exactly what’s going on with a user’s account state instantly. It saves you from parsing encoded strings when you just need to know if someone is locked out.

passwd -S username

⚙️ Why It Works

The output gives you the login name followed by a status character like L for locked, NP for no password, or P for a usable password. It essentially interprets that messy second field in the shadow file into something readable.

🚀 Pro-Tip: Pipe it through awk ‘{print $2}’ to get just the status code if you are checking a whole list of users in a script.

Linux Tips & Tricks | © ngelinux.com | 11/5/2026

0 0 votes
Article Rating
Exit mobile version