Skip to content

Instantly share code, notes, and snippets.

@ashrithr
Created October 6, 2014 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashrithr/efd4f36777a3674e4d88 to your computer and use it in GitHub Desktop.
Save ashrithr/efd4f36777a3674e4d88 to your computer and use it in GitHub Desktop.
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