Create and Manage Local Groups

LinuxLinuxBeginner
Practice Now

Introduction

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


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389446{{"`Create and Manage Local Groups`"}} end

Create a New Local Group

Tasks

  • Create a new local group named "developers".

Requirements

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

Example

After creating the new group, you should be able to see it in the output of the getent group command:

developers:x:1001:

Add a User to the "developers" Group

Tasks

  • Add the user "john" to the "developers" group.

Requirements

  • The user "john" should be added to the "developers" group using the usermod command.
  • The user "john" should be a valid user on the system.

Example

After adding the user "john" to the "developers" group, you should be able to see the group membership in the output of the id john command:

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

Remove a User from the "developers" Group

Tasks

  • Remove the user "john" from the "developers" group.

Requirements

  • The user "john" should be removed from the "developers" group using the gpasswd command.
  • The user "john" should still exist on the system after the removal.

Example

After removing the user "john" from the "developers" group, you should be able to see the updated group membership in the output of the id john command:

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

Delete the "developers" Group

Tasks

  • Delete the "developers" group.

Requirements

  • The "developers" group should be deleted using the groupdel command.
  • The group should no longer exist after the deletion.

Example

After deleting the "developers" group, you should not be able to see it in the output of the getent group command:

$ getent group developers
getent: developers: group not found

Summary

In this challenge, you learned how to create, add users to, remove users from, and delete local groups on a Linux system. These skills are essential for system administrators to manage user access and permissions effectively. You practiced using the groupadd, usermod, gpasswd, and groupdel commands to perform these tasks.

Other Linux Tutorials you may like