Useful Commands For User and Group Management in Linux?

In this article, I will explain how we can manage users and groups in RHEL. Here You will learn how to add and remove a single user, how to make a group, how to add different users in a separate group. And you will also learn that how you can add multiple users through a scripted program in RHEL. Along with you will also learn how we can keep the database of users and groups and how we can modify the user and group info.

Guys this is a basic article about management of users and groups. So to understand the advanced level of users and groups management you have to read this article. Keep your eyes with full concentration on every step given below

Let's start the management of the user and group in Linux.

How to add a user in Linux

[root@localhost ~]# useradd Deepak

How to add a password to the user of Linux

[root@localhost ~]# passwd deepak

How to delete the password of a user

[root@localhost ~]# passwd -d Deepak

How to remove any user of Linux

[root@localhost ~]# userdel -r Deepak

How to see the database of a user in Linux

[root@localhost ~]#cat /etc/passwd

(type this command only, below database will be automatically shown on desktop)

rohit:x:500:500::/home/rohit:/bin/bash

rdsaini:x:501:501::/home/rdsaini:/bin/bash u1:x:502:502::/home/u1:/bin/bash u2:x:503:503::/home/u2:/bin/bash

u3:x:504:504::/home/u3:/bin/bash ldap:x:55:55:LDAP

User:/var/lib/ldap:/bin/false ais:x:39:39:openais Standards Based Cluster Framework:/:/sbin/nologin

mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash

Dinesh:x:505:507::/home/dinesh:/bin/bash

Deepak:x:506:508::/home/Deepak:/bin/bash

[root@localhost ~]

How to check the user is Password Protected or not

[root@localhost ~]# cat /etc/shadow

(If the user is password Protected then there will be the encrypted format of characters in front of username)

Deepak:x:506:508::/$%^ua&^hi8763h7642ggwe3$%^$gu987

How to search a user id from the database

[root@localhost ~]# grep Deepak /etc/passwd

Know extra info about user in the database

[root@localhost ~]# whatis useradd


[root@localhost ~]# whereis useradd

How to add a Group in Linux

[root@localhost ~]# groupadd admin

How to see the database of Group

[root@localhost ~]# cat /etc/group

Add a user to a particular group

[root@localhost ~]# usermod -G admin Deepak
(admin - It is name of group, Deepak - It is name of User)

Note - You can add the many users in a group but before you have to add some users to your system.

Check whether your user added to your group or not

[root@localhost ~]# cat /etc/group

How to remove a group from Linux

[root@localhost ~]# groupdel admin

How to remove a user from a Group

[root@localhost ~]# gpasswd -d Deepak admin

(-d for delete, Deepak is the Username, admin is the group name)

This post is all about how we can do user and group management in Linux. So Guys if you have doubt or any query about this post then don’t hesitate to contact me. And if you have any suggestions for me then please write to me the comment box. If you like my posts please share it with your friends

  

Post a Comment

0 Comments