Non password entries of passwd file | IT Skill Development Portal

Non password entries of passwd filecan't see properly

[copya id="link_3743816655" target="3743816655"]copy[/copya]
[t_block id="3743816655" ]#!/bin/bash
#Script that looks non password entries from passwd file

# Shell script for search for no password entries and lock all accounts
# Set your email

### Do not change anything below ###
#LOG File

echo "-------------------------------------------------------" >>$LOG
echo "Host: $(hostname), Run date: $(date)" >> $LOG
echo "-------------------------------------------------------" >>$LOG

# get all user names
USERS="$(cut -d: -f 1 /etc/passwd)"

# display message
echo "Searching for null password..."
for u in $USERS

# find out if password is set or not (null password)
passwd -S $u | grep -Ew "NP" >/dev/null
if [ $? -eq 0 ]; then # if so

echo "$u" >> $LOG
passwd -l $u #lock account
STATUS=1 #update status so that we can send an email


echo "========================================================" >>$LOG
if [ $STATUS -eq 1 ]; then
echo "Please see $LOG file and all account with no password are locked!" >$TMPFILE
echo "-- $(basename $0) script" >>$TMPFILE
mail -s "Account with no password found and locked" "$ADMINEMAIL" < $TMPFILE
# rm -f $TMPFILE

Loading Questions

If you are facing any issue like can not see video so please login into Google with email what you forwarded to us Google Login or mail to administrator