User & Group Management
Stop manually hunting for users who forgot to set a home directory
đź§© The Challenge
Dealing with a new hire’s account and realized you accidentally created a user without a home directory, or worse, one with a broken path? I’ve wasted plenty of time manually checking /etc/passwd just to find the one user who can’t log in because their shell is pointing at thin air.
đź’ˇ The Fix
Use getent to pull the user database and throw a quick grep or awk at it to flag anyone whose home directory doesn’t actually exist on the disk. It saves you from that “why is my home directory just /?” support ticket later in the day.
getent passwd | awk -F: '$6 != "/" && ! -d $6 {print $1, $6}'
⚙️ Why It Works
This pulls the full list of system users and checks their home field against the filesystem, printing only the accounts where that directory is missing. It’s much faster than grepping through files when you’re managing hundreds of accounts.
🚀 Pro-Tip: Pipe that to xargs mkdir -p if you’re feeling brave and just want to fix them all at once.
Linux Tips & Tricks | © ngelinux.com | 8/20/2026
