Skip to content

Instantly share code, notes, and snippets.

@DrSnowbird
Last active September 8, 2018 18:51
Show Gist options
  • Save DrSnowbird/10601079e4a88dd2c1294ee9f1cccf6b to your computer and use it in GitHub Desktop.
Save DrSnowbird/10601079e4a88dd2c1294ee9f1cccf6b to your computer and use it in GitHub Desktop.
#!/bin/bash
# ------------------------------------
# maintainer: [email protected]
# license: Apache License Version 2.0
# ------------------------------------
if [ $# -lt 2 ]; then
echo "*** ERROR ***"
echo "... Need two input arguments ..."
echo "$(basename $0) <User_Name> <Password>"
exit 1
else
USER_NAME=${1}
USER_PASSWD=${2}
sudo useradd -U -d /home/${USER_NAME} --create-home -s /bin/bash -p $(echo ${USER_PASSWD} | openssl passwd -1 -stdin) ${USER_NAME}
echo "------------------------------------"
echo "To add user to more group:"
echo "sudo usermod -aG <new-Group> ${USER_NAME}"
echo " Note: The user will need to log out and log back in to see the new group added."
echo "------------------------------------"
echo "To add user to sudo group:"
echo "sudo usermod -aG sudo ${USER_NAME}"
echo "------------------------------------"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment