Linux Shell Script to create Multiple Users and Expire Password


Example Script to create multiple users in linux at same time.Remember this has to be executed via administrative user or root.


for u in kevin nancy scott ; do
useradd $u
echo "$u:Password1" | chpasswd
passwd -e $u
done

We can also create a file and pass any number of users.

Sample file

$ cat newusers

himanshu
kevin
bob
marley
nancy


for u in `cat newusers` ; do
useradd $u
echo "$u:Password1" | chpasswd
passwd -e $u
done