Create Single user & multiple users at a time in Linux

  Create single user

Create a single user (mushfiq) and give his password:

useradd  mushfiq ; passwd mushfiq

Mushfiq has to change his password at his first login forcefully:

change  -d  0 mushfiq



 Create multiple users at a time

Way-01: By command (for  loop)

for staff in miraz bulbul abaten; do useradd $staff;echo 12 | passwd --stdin $staff; chage -d 0 $staff;done


** staff = is a variable

** 12 = common password of all users

** See this task at below video link:





Way-02: Creating a user list file

vim /etc/create-users

    imran:12:1010:1010:He is the IT guy:/home/imran:/bin/bash

    bulbul:12:1011:1011:He is the IT guy:/home/bulbul:/bin/bash

    miraz:12:1012:1012:He is the IT guy:/home/miraz:/bin/bash

    towhid:12:1013:1013:He is the IT guy:/home/towhid:/bin/bash


chmod 700 /etc/create-users 

newusers /etc/create-users


** 12 = users password

** First 1010/1011/1012/1013  is the users ID 

** Second 1010/1011/1012/1013  is the group ID 

** See this task at below video link:




Way-03: Creating multiple users by sequence number

for a in `seq 1 5`; do 

useradd myuser$a; 

echo mypass$a | passwd --stdin myuser$a; 

chage -d 0 myuser$a; done

                                            


Way-04: Creating multiple users by creating executable file

vim admin-users.txt

it-admin

hr-admin

sales-admin


# vim  user-add.sh

#!/bin/sh

for user in `more admin-users.txt`

do

useradd $user

echo "$user@123" | passwd --stdin "$user"

chage -d 0 $user

done


# chmod +x user-add.sh


                                                                


Comments

Popular posts from this blog

Some Questions for MTCNA Exam

ডিপ্লোমা লেভেল এর ইন্ডাস্ট্রিয়াল এটাচমেন্ট এ আসার পূর্বে একটু ভেবে আসার অনুরোধ রইলো

Basic Router & Switch IOS commands