To iterate over any unique user, you can get the contents of the file passwdand get the first token of each line.
I would suggest using it getent passwdfor reading passwd, since it /etc/passwdcontains only users from local machine files (for example: there are no users from LDAP or other PAM plugins).
getent passwd | cut -d':' -f1
This command returns one user per line.
Then lastthey idtell you their last login and their group:
for user in `getent passwd | cut -d':' -f1`
do
id ...
last ...
done
peoro source
share