How to give password in shell script for user creation


#1

HI Team,

I am planning to create 1000 user on one my linux system using the shell script.

The issue i am facing how can i give password to all the users automatically.

EX:
useradd test1
passwd for All user is 12345

IF i type passwd command it will expect output from user. How to provide password “12345” automatically to all user.

Please help on this


#2

It’s very simple

i=use1 use2 user3 …user100
for i in 100
do
echo “password” | passwd “$i” --stdin
done


#3

Thank you so much Narendra. This is what exactly i am looking for


#4

for i in seq 1 100
do
useradd user$i
echo “password” | passwd “user$i” --stdin
done