Skip to content

Instantly share code, notes, and snippets.

@ashrithr ashrithr/users.sh
Created Oct 6, 2014

Embed
What would you like to do?
Linux users with password and currently logged in
#!/bin/bash
users_with_pwd=$(awk -F":" '!($2 == "" || $2 == "!!" || $2 == "*") {print $1}' /etc/shadow)
users_logged_in=$(who | awk '{print $1}' | uniq)
echo "[*] Users with password: "
for user in ${users_with_pwd}; do
echo $user
done
echo "[*] Users currently logged in: "
for user in ${users_logged_in}; do
echo $user
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.