1.
Simple Script to add multiple users in one go.
#!/bin/bash
filename="userslist.txt" #< contains list of user's
while read -r username
do
name=$username
echo "User created : " $username
useradd $username
done < $filename
2.
Simple script to provide a password to the list of user’s in one go.
#!/bin/bash
filename="userslist.txt"
password="redhat" #< provide password of your choice
while
read -r username
do
name=$username
echo "password provided for user :" $username
echo "$password" | passwd $username --stdin
done
< $filename
3.
Simple script to change the shell of the bulk of user’s in one go.
#!/bin/bash
filename="userslist.txt" #< contains list of user's whose shell going to change
while
read -r username
do
name=$username
echo "changing shell for user :" $username
chsh -s /sbin/nologin $username #< provide the shell you want to change
to.
done
< $filename
No comments:
Post a Comment