Created
March 25, 2016 13:08
-
-
Save mkjasinski/f92630186b0a4d9b2a1d to your computer and use it in GitHub Desktop.
[linux] - bash script to creation users from file with logins
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 | |
for user in `cat ~/.my-users-to-add | grep -v "#"`; do | |
echo "Adding user [$user] ..." | |
if id -u "$user" >/dev/null 2>&1; then | |
echo "User $user exists" | |
else | |
useradd --shell /bin/bash -m $user | |
echo $user:$user | chpasswd | |
chmod ugo-rwx,ug+rwX /home/$user | |
chmod g+s /home/$user | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment