Skip to content

Instantly share code, notes, and snippets.

@mkjasinski
Created March 25, 2016 13:08
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 mkjasinski/f92630186b0a4d9b2a1d to your computer and use it in GitHub Desktop.
Save mkjasinski/f92630186b0a4d9b2a1d to your computer and use it in GitHub Desktop.
[linux] - bash script to creation users from file with logins
#!/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