Automating Users and Passwords

Hey guys in this simple post i will show you how you could easily create passwords of multiple users with a simple script.

!/bin/bash
 file=/user.txt
 for i in more $file
 do
 useradd $i
 newpass=mkpasswd
 echo "user $i added successfully"
 echo "$newpass" | passwd --stdin "$i"
 echo "password for user $i is $newpass"
 done

Just create a file user.txt in / directory and add users to this file.

give executable permissions to the file and run by typing e.g
# sh file.sh

Thanks,

Salman A. Francis
https://youtube.com/linuxking
https://facebook.com/linuxking77
Insta: Linuxking77
Twitter: @Linuxking77

Leave a Comment

Your email address will not be published. Required fields are marked *