User and Group Management - RHCSA
How to add users to a group?
We can do it in two different ways.- While creating a user
- After creating a user
- Add to a supplementary group
Let assume group name is HR. After creating the group retrieve it using tail -n 5 /etc/group or
cat /etc/group | grep HR
After that you have to create a user by using following command.
-G for add group as supplementary group
You can retrieve information by using id command.
Example:
- Add to a primary group
cat /etc/group | grep <group name>
Using that command you can get the gid. Remember that you have to replace <group name>.
After that use following command.
<gid> should be replaced by using relevant gid.
After that u need to verify it. Use id command.
id <user name>
After creating a user: After user was created we need to modify the user by using usermod command.
Add user to a supplementary group, use following command
Verify using id command
Add user to a primary group , use following command
Verify using id command
Exercise:
Create users called Andrew, Paul, Mark, Susan, Kent. User id should be started from 5000. Andrew and Paul are in Cooking group as their supplementary group. Susan and Kent are in Service group as their supplementary group. Mark is in both groups. But his primary group is Management.
Comments
Post a Comment
Thank you for your comment