Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreiTelteu/b6468e7ef1b5d72b080e22775fba6e05 to your computer and use it in GitHub Desktop.
Save AndreiTelteu/b6468e7ef1b5d72b080e22775fba6e05 to your computer and use it in GitHub Desktop.
Linux script create user and group if not exists
#!/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