Created
July 2, 2023 14:54
-
-
Save AndreiTelteu/b6468e7ef1b5d72b080e22775fba6e05 to your computer and use it in GitHub Desktop.
Linux script create user and group if not exists
This file contains hidden or 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_NAME=app | |
cat /etc/passwd | grep ${USER_NAME} >/dev/null 2>&1 | |
if [ $? -eq 0 ] ; then | |
echo "user ${USER_NAME} exists" | |
else | |
groupadd -r ${USER_NAME} -g 1000 && useradd -u 1000 -r -g ${USER_NAME} -m -d /home/${USER_NAME} -s /bin/bash -c "App user" ${USER_NAME} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment