12345678910111213141516171819202122 |
- #!/bin/bash
- echo "---------------------------------------------------"
- echo "USERNAME EXP DATE STATUS"
- echo "---------------------------------------------------"
- while read expired
- do
- AKUN="$(echo $expired | cut -d: -f1)"
- ID="$(echo $expired | grep -v nobody | cut -d: -f3)"
- exp="$(chage -l $AKUN | grep "Account expires" | awk -F": " '{print $2}')"
- status="$(passwd -S $AKUN | awk '{print $2}' )"
- if [[ $ID -ge 1000 ]]; then
- if [[ "$status" = "L" ]]; then
- printf "%-17s %2s %-17s %2s \n" "$AKUN" "$exp " "${RED}LOCKED${NORMAL}"
- else
- printf "%-17s %2s %-17s %2s \n" "$AKUN" "$exp " "${GREEN}UNLOCKED${NORMAL}"
- fi
- fi
- done < /etc/passwd
- JUMLAH="$(awk -F: '$3 >= 1000 && $1 != "nobody" {print $1}' /etc/passwd | wc -l)"
- echo "---------------------------------------------------"
- echo "Account number: $JUMLAH user"
- echo "---------------------------------------------------"
|