I have already written two articles on User and Group management in Linux.here in this article mostly i focused on how to create and delete multiple users or multiple groups in linux at a time.And we will also learn How to create a series of Linux Users in a sequence like from U1 to U100 at a time and delete them.

User and Group Management For Linux User Part-1
User and Group Management For Linux User Part-2
How to Lock and unlock Users in Linux in Detail.

And Now this is part-3 of User and Group Management Tutorial in Linux.

1.How to Create  Multiple Groups in Linux  at a time.

Here in this Example linux Lab I am going to Create 6  Groups named A  B  C  D  E and F respectively.

[root@localhost ~]# for GROUP in A B C D E F
> do
> groupadd $GROUP
> done

Now you can check the ouptput and analyse whether Groups Created or not.

[root@localhost ~]#cat /etc/group
A:x:908:
B:x:909:
C:x:910:
D:x:911:
E:x:912:
F:x:913:

2.How to Delete Multiple Groups at a Time.

Here in This Linux Lab I am going to Delete all those Groups I have Created through above command.

[root@localhost ~]# for GROUP in A B C D E F
> do
> groupdel $GROUP
> done
[root@localhost ~]#

3.How to Add Multiple User at a time and assign same password to all of them.

Here in this Example Linux Lab I am going to Create 3 Linux User Named shivangi  shalu and shreya and Password for all these thre users will be satishtiwary.

[root@localhost ~]# for USER in shivangi shalu shreya ; do useradd $USER; echo satishtiwary |passwd --stdin $USER; done
Changing password for user shivangi.
passwd: all authentication tokens updated successfully.
Changing password for user shalu.
passwd: all authentication tokens updated successfully.
Changing password for user shreya.
passwd: all authentication tokens updated successfully.
[root@localhost ~]#

 

4.How to Delete Multiple User in Linux at a Time.

Now again I am going to Delete all Users i have created in above command. So here below command will Delete User shivangi shreya and shalu Users.

[root@localhost ~]# for USER in shivangi shreya shalu
> do
> userdel -r $USER
> done
[root@localhost ~]#

 

5.How to Create Linux Users from user10 to user60 at a time having each user Blank Password or No Password.

Here in this Example Linux Lab I want to Create Users named User10, User11,User12 up to user60. And also all the users have Blank Password or No Password.

[root@localhost ~]# for i in user{10..60}
> do
> useradd $i;
> passwd -d $i;
> done

6.How to Delete all above Users  (user10 to user60) in a single command.

Now I am going to Delete all users i have created in above command.

[root@localhost ~]# for i in user{10..60}; do userdel -r $i; done

 

7.You want to count number of Users logged in with time/date stamp.how you will you do this?

[root@localhost ~]# date;who|wc -l
Sat Jan 21 02:28:51 EST 2017
5


You can check using below comand and you will find the result is correct:

[root@localhost ~]# who
root     tty1         2017-01-21 00:54
root     tty4         2017-01-21 00:52
u1       tty5         2017-01-21 02:28
u2       tty6         2017-01-21 02:28
root     pts/1        2017-01-21 01:53 (192.168.0.111)


very soon you will see the Linux User and Group management Tutorial Part-4.
I hope you like the tutorial.If you realy like it then share it and share your views through comments.
Advertisements
Comments
  1. Sumit Sharma says:

    thank you sir , this is very useful. i am a new user please share more links and pdf files. thanks again sir.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

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