RHCSA Practical Lab Series – User & Group Management

Expertise in Cloud, Networking & DevOps
Photo by Daniel Leone / Unsplash

πŸ” Lab 4: Creating User Accounts and Group Permissions

πŸ“Œ Objective

In this lab, you will:

βœ” Create a new user group
βœ” Add users with specific group memberships
βœ” Restrict shell access for a specific user
βœ” Set passwords for all users


πŸ“Œ Step 1: Create the User Group

We first need to create a group called sysadmins:

[root@node1 ~]# groupadd sysadmins

πŸ“Œ Tip: The groupadd command creates a new group. You can verify its creation using:

[root@node1 ~]# cat /etc/group | grep sysadmins

πŸ“Œ Step 2: Create Users and Assign Group Memberships

Now, we will create three users (alice, bob, and charlie) with the following rules:

πŸ”Ή alice should be a member of sysadmins

[root@node1 ~]# useradd -G sysadmins alice

πŸ”Ή bob should also be a member of sysadmins

[root@node1 ~]# useradd -G sysadmins bob

πŸ”Ή charlie should not have shell access and should not be in sysadmins

[root@node1 ~]# useradd -s /bin/false charlie

πŸ“Œ Tip:

  • -G sysadmins β†’ Adds the user to the sysadmins group.
  • -s /bin/false β†’ Prevents the user from logging into the shell.

πŸ”Ή Verify group membership:

[root@node1 ~]# id alice
[root@node1 ~]# id bob
[root@node1 ~]# id charlie

πŸ”Ή Expected Output (example for alice):

uid=1001(alice) gid=1001(alice) groups=1001(alice),1002(sysadmins)

πŸ“Œ Step 3: Set User Passwords

The passwords for all users (alice, bob, charlie) should be cloudnetops.

[root@node1 ~]# echo cloudnetops | passwd --stdin alice
[root@node1 ~]# echo cloudnetops | passwd --stdin bob
[root@node1 ~]# echo cloudnetops | passwd --stdin charlie

πŸ”Ή Verify the password has been set (prompt for password change should not appear):

[root@node1 ~]# su - alice

Enter cloudnetops as the password and ensure login is successful.

πŸ“Œ Tip:

  • The echo cloudnetops | passwd --stdin username command sets a password in a single step.
  • If su - charlie fails, it means shell access has been successfully restricted.

πŸ“Œ Step 4: Verify User Restrictions

πŸ”Ή Test login for alice (should succeed)

[root@node1 ~]# su - alice

πŸ”Ή Test login for charlie (should fail due to restricted shell access)

[root@node1 ~]# su - charlie

πŸ”Ή Expected Output:

This account is currently not available.

βœ… If charlie cannot log in, the shell restriction is working correctly.


βœ… Final Summary

In this lab, you successfully:
βœ” Created a new group (sysadmins)
βœ” Created three users (alice, bob, and charlie)
βœ” Added alice and bob to sysadmins
βœ” Restricted shell access for charlie
βœ” Set passwords for all users


πŸ“Œ Next Lab: Automating Tasks with Cron Jobs

Objective

πŸ“© Subscribe for more RHCSA exam labs and hands-on tutorials! πŸš€


Read more