Create Group And User Using Command line In CentOS 7

Today we will learn how to Create User and Group using the command line in Linux. In the previous post, we learned about Some useful commands of the user. We can also remove and find the location of the user in Linux.

Create Group and User Using Command line:

You can also add a user with this command adduser username. if you need to remove a user with all the locations. So you can simply use the ‘-r‘ option with userdel -r username

Check Out: Useful Commands of “Useradd“

Both commands mention below used to add a user in Linux.

useradd aryan Or adduser aryan

Check User added.

grep aryan /etc/passwd

 user location in linux

Now a few things to keep in mind when you created is the user. It’s defined in 5 locations which is mentioned below.

Check Out: Delete Users In Ubuntu

1. Working Home Directory


2. Mail location

ls /var/spool/mail/

3. It creates a primary group

grep aryan /etc/group

1001 = Primary group

4. User password stored here

cat /etc/shadow

5. User information stored here

cat /etc/passwd

Check Out: Force User to Change Password At first 

Create a Group

cat /etc/passwd
groupadd test

Adding a user in a group

usermod -aG test aryan

Now, You can see the user is added in a group. You can add a user in multiple groups by using ‘-a‘.

grep test /etc/group

YouTube Link: Create user and group

That’s it. remove user  create  location in linux

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment