How to create multiple users using shell script in Linux

Step 1: create a file name “useradd.sh” with the content below:

for i in `more $1`
do
echo $i
useradd -m -g G_Staff $i
echo “1234567” | passwd –stdin “$i”
done

Step 2. set execute permission to this file:
chmod +x useradd.sh

Step 3. create a file name “users.txt” with the contents like below:

user1
user2
user3

Step 4. run this script “useradd.sh” with the file “users.txt”, then it will create user1, user2 & user3 with password “1234567”

./useradd.sh users.txt

Done,
Any question, contact the blog owner.

6 comments on “How to create multiple users using shell script in Linux

  1. Pingback: membuat multiple user dengan script bash di Debian | Walid Umar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s