Created
February 8, 2019 14:37
-
-
Save smashnet/48873e70db97c864295f5fb398b63472 to your computer and use it in GitHub Desktop.
Add new no-shell-user and add self to group
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 | |
if [ -z "$1" ]; then | |
echo "Please provide a name for the new user!" | |
exit 1 | |
fi | |
echo "Creating user and group -$1- and adding you ($(whoami)) to that group." | |
echo -n "Sure ye wanna do this? (y/N) -> " | |
read answer | |
if [ "$answer" == "y" ] || [ "$answer" == "Y" ]; then | |
echo "Doing it so!" | |
sudo useradd -r -s /sbin/nologin $1 | |
sudo usermod -a -G $1 $(whoami) | |
echo "Done!" | |
echo $(id $1) | |
else | |
echo "Ok, did not do anything... bye!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment