This post describe how to find out whether the user name is exist in your system using shell script.
Create a file name checkuser.sh and give execute permission,
# touch /root/checkuser.sh
# chmod +x /root/checkuser.sh
# chmod +x /root/checkuser.sh
#!/bin/bash
echo " Enter the User Name : "
read USR_NAME
if id -u $USR_NAME >/dev/null 2>&1; then
echo "The User Name is Already Exist, Give Different Name"
else
useradd $USR_NAME
fi
local@host# /root/checkuser.sh
If the user name is does not exist create a new user.
Comments (0)