Linux Shell script to Add user with password to the system

Linux Shell script to Add user with password to the system

We often need to create unix users and need to assign password.This is quite Simple but if we have to create multiple users and need to assign the password to them,then its quite difficult. Below script will help in the desired task.

Hence first create a file user password which consists of user in the first column and password in the second column.

root@s:~# cat userpasswd
user1:password1
user2:password2
user3:password3
user4:password4
user5:password5

Run the below script to add users.

root@pri:~# for i in `cat user`; do echo $i; useradd $i ;done
user1
user2
user3
user4
user5
root@pri:~# cat userpasswd | chpasswd

Leave a Reply

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