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
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
3. It creates a primary group
grep aryan /etc/group
1001 = Primary group
4. User password stored here
5. User information stored here
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