Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/user-add.sh
Last active Apr 14, 2020

Embed
What would you like to do?
Add user with cusmoized useradd command
#!/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
You can’t perform that action at this time.