Skip to content

Instantly share code, notes, and snippets.

@duven87
Created October 10, 2018 16:46
Show Gist options
  • Save duven87/678f18a56867f648cba2df7aa33664b9 to your computer and use it in GitHub Desktop.
Save duven87/678f18a56867f648cba2df7aa33664b9 to your computer and use it in GitHub Desktop.
mkuser
#!/bin/bash
#
# Create account user and pass
################################
#Obtain valor variable
#######################
while [ "$Username" != "Exit" ]
echo
echo -e "Please enter username for account or type Exit: \c"
read Username
do
# Create account of user ###
useradd $Username
#Check if variable had content:
#######################################
if [ -z $Username ]
then
echo
echo You didnt provide a username
echo Leaving script..
exit
fi
case $Username in
Exit)
echo Leaving script..
exit
;;
*)
echo
echo Account for $Username is being created...
;;
esac
#Define pass for the account
#############################
echo Password for $Username is being set..
echo
passwd $Username
# Show reg. of the account
#
User_Record=$(grep $Username /etc/passwd)
#
echo
echo here is $Username \'s record\:
echo $User_Record
echo
#
echo Account is ready for use.
done
echo Leaving script...
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment