Last active
April 14, 2020 16:05
-
-
Save peter279k/9c6c96d0fa26bee320195a7539a5de6c to your computer and use it in GitHub Desktop.
Add user with cusmoized useradd command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USER=$1 | |
[[ $USER = "" ]] && echo 'Please set a user name' && exit; | |
useradd -s /bin/bash ${USER} | |
[[ $? -ne 0 ]] && echo 'You should have root permission!' && exit; | |
mkdir /home/${USER} | |
chown -R ${USER}:${USER} /home/${USER} | |
echo "Creating ${USER} has been done..." | |
echo "Don't forget to use passwd to set password for ${USER}!" | |
printf "\n" | |
echo "Add User to sudo group......" | |
gpasswd -a ${USER} sudo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment