What a day!
I have to install a new server (RHEL 5), and have to create about 15 of local user for this server. It’s not like a “pain in the ass” since it’s just one server. But how about 10 or more servers? It will be a headache for any sysadmin…
These two scripts are very important for the sysadmin who regularly works with some servers and somehow forgets to backup his system username and password! Let’s say somehow we lost the usernames and passwords of the mail server. In this case the admin has to manually create all the users and then change the passwords for all the users. Tedious job. Let’s make our life easier.
First create a file which contains all the user name. Something like this:
anton mark chief steve robin anum
Save the file as user.txt. Now create the following bash file:
#!/bin/sh for i in `more user.txt ` do echo $i adduser $i done
Save the file as usercreate.sh and exit.
chmod 755 usercreate.sh
Now run the file:
./usercreate.sh
This will add all the users to the system. Now we have to change the passwords. Let’s say we want username#789 as password. So for user anton the password will be anton#789, robin#789 for user robin and so on.
Create another bash file as follows:
#!/bin/sh for i in `more user.txt ` do echo $i echo $i"789" | passwd –-stdin "$i" done
Save the file as changepass.sh. Do the chmod necessarily, and Run the file. All the passwords will be changed.


You must log in to post a comment.