Created
November 10, 2017 11:06
-
-
Save ravihara/58e4f51dc0913cd2e1cbe6df75540759 to your computer and use it in GitHub Desktop.
Shell script to add a system user
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 -e | |
# Add a system user in Linux | |
if [ $UID -ne 0 ]; then | |
echo "You must be a root / superuser, in order to run this script. $(basename $0) aborted." | |
exit 1 | |
fi | |
if [ $# -ne 3 ]; then | |
echo "Usage: $(basename $0) <user-name> <user-home> <gecos-string>" | |
exit 2 | |
fi | |
echo "Adding system-user $1 with home-dir at $2 and description $3 ..." | |
adduser --system --shell /bin/bash --gecos '$3' --group --disabled-password --home $2 $1 | |
echo "DONE." | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment