User & Group Management
Stop checking /etc/passwd manually when you need to audit login shells
🧩 The Challenge
Dealing with a dozen users who still have /bin/sh or worse, /bin/false, when they actually need a real shell is a headache. Grepping through flat files is a relic of the past and frankly, it’s just slow.
💡 The Fix
Use getent to query the database directly instead of parsing local files yourself. It’s way faster and respects whatever auth provider is actually running, like LDAP or SSSD.
getent passwd | awk -F: '$NF !~ /nologin|false/ {print $1, $NF}'
⚙️ Why It Works
By pulling the entire passwd database through getent, you bypass the headache of local file formats and let the system resolve the actual active users for you. It handles those weird edge cases where users aren’t even defined in /etc/passwd.
🚀 Pro-Tip: Pipe that output into column -t if you want to keep your eyes from crossing while reading the list.
Linux Tips & Tricks | © ngelinux.com | 8/20/2026
