Managing User and Group in Linux

This blog features the how manage user and group in linux.

A great percentage of customer retention is the ultimate growth strategy

Managing user AND Group in Linux



Linux hasa unique feature that it can manage multiusers at the same time. So, it is alsoknown as Multiuser operating system. In linux, at the same time multipleusers can work in same group and on same file. Linux is designed in a such waythat multiple users can access the system at the same time but with somepermission given to each user so that every user can work properly and theirwork must be protected.

User groups play a vital role on Linux systems. They providean easy way for selected groups of users to share files with each other. Theyalso allow sysadmins to more effectively manage user privileges, since they canassign privileges to groups rather than individual users.




Understanding Sudo

Sysadmin or System admin are the one who will have sudoprivileges or root privileges. sudo is an abbreviation of “superuser do”. A sudo user is generally used in the place of root. Foradding a new user to the system, we need to deal with an account other thanyour own account for that we need super user privileges.

So, we need to apply sudo before each command to run the commandusing sudo privileges or we need to hit sudo su - command tobecome a sudoer or superuser.


How to add user and group

To add user in the system we used adduser/useradd command. If we used -m with adduser it will create home directoryfor user. Even a group with same as that of user is created. The accountiformation is stored in following format:

[username]:[x]:[uid]:[gid]:[Comment]:[homedirectory]:[default shell]


sudo adduser username

The user is added successfully to the /etc/passwd file in the system.  To check whether the user is present in /etc/passwd file we need to hit following command:

sudo cat /etc/passwd

For ex:

To set the password for user we used passwd command. When we hit the following command, it will ask to enter password for the user.


sudo passwd username

For Ex:

To add group in the system we used groupadd command. We can then add users to this group with certain privileges on files.


sudo groupadd groupname

For ex:


The group is added to /etc/group file in thesystem. To check whether it is added successfully or not just hit the belowcommand.

sudo cat /etc/group

For ex:

To modify the user in the system we used usermod command. You can change details associated with the user like changing the home directory, expiry date, shell that user logins, append groups, lock the user, etc.


 sudo usermod -a -G groupnameusername

For ex:

To delete or to remove the user from the system we use userdel command.


sudo userdel username

For ex:

To delete or remove group from the system we use groupdel command.


sudo groupdel groupname

For ex:

 Thank you for reading !!

Want to know about internship and training programme ?
Just Subscribe here.

Will help out in learning all the DevOps and DevSecOps tool and you will get an hands-on experience as well.
Grab the opportunity and join us !

Thanks for joining our newsletter.
Oops! Something went wrong.