Tags

, , , ,

This two scripts are very important for the system admin who regularly works with mail server and some how forget to backup their system username and password!!!. Let’s say some how we lost the server username and password of the mail server. In this case the admin has to manually create all the users and than change the password for all the user. Tedious job :-). Let’s make our life easier.

First create a file which contains all the user name. Something like this:



nurealam
nayeem
mrahman
farid
rubi
sankar




Save the file as userlist.txt

Now create the following bash file:



#!/bin/sh
for i in `more userlist.txt `
do
echo $i
adduser $i
done

Save the file and exit. chmod 755 userlist.txt. Now run the file by ./userlist.txt. This will add all the user to the system.

Now we have to change the password. Lets say we want username123 as password. So for user nayeem the password will be nayeem123, rubi123 for user rubi and so on.


Create another bash file as following:



#!/bin/sh
for i in `more userlist.txt `
do
echo $i
echo $i”123” | passwd —stdin “$i”
echo; echo “User $username’s password changed!”
done

Run the file. All the password are changed 🙂