Create and Manage Local Groups

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to create, delete, and modify local groups on a Red Hat Enterprise Linux system. This is an essential skill for system administrators to manage user access and permissions effectively.

Create a New Local Group

Your first task is to create a new local group. This is a common administrative task for organizing users with similar access needs.

Tasks

  • Create a new local group named developers.

Requirements

  • The new group must be created using the groupadd command.
  • The group name must be exactly developers.

Example

After creating the new group, you can verify its existence by checking the /etc/group file or using the getent command. The output should be similar to the following, though the Group ID (GID) may differ:

developers:x:1001:

Add a User to a Group

Now that the developers group exists, you will add an existing user to it. This grants the user the permissions associated with that group.

Tasks

  • Add the user john to the developers group.

Requirements

  • The user john must be added to the developers group as a supplementary group.
  • Use the usermod command to modify the user's group membership.
  • Ensure that john's primary group is not changed.

Example

After adding john to the group, you can check his group memberships with the id command. The output should show developers in the list of groups.

uid=1002(john) gid=1003(john) groups=1003(john),1002(developers)

Remove a User from a Group

Next, you will practice removing a user from a group. This is a common task when a user's role changes and they no longer need access associated with a particular group.

Tasks

  • Remove the user john from the developers group.

Requirements

  • The user john must be removed from the developers group using the gpasswd command.
  • The user john must still exist on the system after being removed from the group.

Example

After removing john from the developers group, the id john command should no longer list developers in his group memberships.

uid=1002(john) gid=1003(john) groups=1003(john)

Delete a Group

Finally, you will delete the developers group entirely. This is done when a group is no longer needed.

Tasks

  • Delete the developers group.

Requirements

  • The developers group must be deleted using the groupdel command.
  • After deletion, the group should no longer exist on the system.

Example

After deleting the developers group, running getent group developers will produce no output, confirming that the group has been removed.

getent group developers

(This command will produce no output and exit with a non-zero status code.)

Summary

In this challenge, you have learned the fundamental operations for managing local groups on a Red Hat Enterprise Linux system. You practiced creating a group with groupadd, adding a user to a group with usermod, removing a user from a group with gpasswd, and deleting a group with groupdel. These commands are essential tools for any system administrator responsible for user and access management.

✨ Check Solution and Practice✨ Check Solution and Practice✨ Check Solution and Practice✨ Check Solution and Practice