! # / bin / bash
#author: ELIN
#date: 2019.8.27
#title: user management system
#author: ELIN
#date: 2019.8.27
#title: user management system
User page #
# input command
the while to true
do
echo "============================ // \\"
echo "| user management system | "
echo" -------------------------------- "
echo" | 1, create a user | "
echo" | 2 , delete users | "
echo" | 3, lock the user | "
echo" | 4, unlock the user | "
echo" | 5, view the user | "
echo" | 6, exit the script | "
echo" ------- ------------------------- "
the Read -p" Please enter your OS choice: "AA
IF [$ AA -eq 1]
the then
{the Read -p "Please enter your username:" bb
[ -d /home/$bb ]
if [ $? -eq 0 ]
then
echo "User already exists, please enter the correct user name !!"
the else
useradd $ bb
the Read -p "Please enter your password:" CC
echo "$ CC" | passwd --stdin $ bb &> / dev / null
echo "password successfully"
fi}
# input command
the while to true
do
echo "============================ // \\"
echo "| user management system | "
echo" -------------------------------- "
echo" | 1, create a user | "
echo" | 2 , delete users | "
echo" | 3, lock the user | "
echo" | 4, unlock the user | "
echo" | 5, view the user | "
echo" | 6, exit the script | "
echo" ------- ------------------------- "
the Read -p" Please enter your OS choice: "AA
IF [$ AA -eq 1]
the then
{the Read -p "Please enter your username:" bb
[ -d /home/$bb ]
if [ $? -eq 0 ]
then
echo "User already exists, please enter the correct user name !!"
the else
useradd $ bb
the Read -p "Please enter your password:" CC
echo "$ CC" | passwd --stdin $ bb &> / dev / null
echo "password successfully"
fi}
elif [$ AA -eq 2]
the then
the Read -p "Please enter the user name you want to delete:" bb
[-d / Home / $ bb]
IF [? $ -eq 0]
the then
userdel -r $ bb
echo "User deleted "
the else
echo" to delete the user does not exist, enter the correct user name !! "
fi
the then
the Read -p "Please enter the user name you want to delete:" bb
[-d / Home / $ bb]
IF [? $ -eq 0]
the then
userdel -r $ bb
echo "User deleted "
the else
echo" to delete the user does not exist, enter the correct user name !! "
fi
Please enter the correct user name! ! "
elif [$ (the passwd -S BB $ | awk '{2} Print $' D) = "LK"]
the then
the passwd -u BB & $> / dev / null
echo "successful user unlocks"
the else
echo "User unlocked"
Fi
elif [$ AA -eq 5]
the then
the Read -p "Please enter the user name you want to see:" bb
[-d / Home / $ bb]
IF [$ -eq 0?]
the then
finger $ bb
the else
echo "user does not exists, enter the correct user name !! "
fi
the else
echo" You have to exit the script "
BREAK
fi
DONE
elif [$ (the passwd -S BB $ | awk '{2} Print $' D) = "LK"]
the then
the passwd -u BB & $> / dev / null
echo "successful user unlocks"
the else
echo "User unlocked"
Fi
elif [$ AA -eq 5]
the then
the Read -p "Please enter the user name you want to see:" bb
[-d / Home / $ bb]
IF [$ -eq 0?]
the then
finger $ bb
the else
echo "user does not exists, enter the correct user name !! "
fi
the else
echo" You have to exit the script "
BREAK
fi
DONE