Skip to content

Instantly share code, notes, and snippets.

@rubenhortas
Last active May 10, 2025 18:54
Show Gist options
  • Select an option

  • Save rubenhortas/e4343380d31cf81605ff4c87f7c0c246 to your computer and use it in GitHub Desktop.

Select an option

Save rubenhortas/e4343380d31cf81605ff4c87f7c0c246 to your computer and use it in GitHub Desktop.
Bash script to find users who have never logged into the system
#!/usr/bin/env bash
# Bash script to find users who have never logged into the system
while IFS=: read -r username _ ; do
last_login=$(lastlog -u "$username" | tail -n 1 | awk '{print $5}')
if [[ -z "$last_login" ]]; then
echo "User \"""$username\""" has never logged in"
fi
done < /etc/passwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment