dump/output/list Linux password expiry info for all users

Solution 1:

A command like this should show you the expiration status for all accounts defined in your /etc/passwd.

cut -f 1 -d: /etc/passwd | xargs -n 1 -I {} bash -c " echo -e '\n{}' ; chage -l {}"

The important command is the chage -l username. That is the command that returns the expiration status for a user. Chage is also the command you would use to modify expiration rules. You may need to add sudo before chage depending on your system setup.

Solution 2:

You can use this simple command also:

awk -F':' '{ system("echo " $1 " && chage -l " $1) }' /etc/passwd

Using awk and system make it more simple.

1. awk -F':' here : is field seperator with /etc/passwd file as input.

2. system("echo " $1 " && chage -l " $1) this will first echo $1 and user's password expiry information with chage -l