Last active
May 10, 2025 18:54
-
-
Save rubenhortas/e4343380d31cf81605ff4c87f7c0c246 to your computer and use it in GitHub Desktop.
Bash script to find users who have never logged into the system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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