Here is a quick tip on how to more or less reliably list all non-system
users and print out status information about their accounts, in linux.
grep -i ':/home/' /etc/passwd | cut -d: -f1 | xargs -n 1 passwd -S
Step 1:
We use grep to look for entries in the /etc/passwd file where the /home/ directory is specified. System users don't normally have such a directory.
Step 2:
We then use cut to retain only the username, and we specify : (colon) as a delimiter.
Step 3:
We run the usernames through xargs to pass each username as a single argument to the passwd -S command.
passwd -S prints out short status of the username. Whether it's locked, expired, etc...
grep -i ':/home/' /etc/passwd | cut -d: -f1 | xargs -n 1 passwd -S
Step 1:
We use grep to look for entries in the /etc/passwd file where the /home/ directory is specified. System users don't normally have such a directory.
Step 2:
We then use cut to retain only the username, and we specify : (colon) as a delimiter.
Step 3:
We run the usernames through xargs to pass each username as a single argument to the passwd -S command.
passwd -S prints out short status of the username. Whether it's locked, expired, etc...
No comments:
Post a Comment