Groups of Linux

LinuxLinuxBeginner
Practice Now

Introduction

Welcome to the lab on Groups of Linux. Linux groups are an essential feature for managing user access and permissions. In this lab, you will learn how to create and delete groups, as well as manage group membership using groupadd and groupdel commands.

For the purpose of this lab, we will use the following specific user name and group name:

  • User name: johndoe
  • Group name: devs

Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/UserandGroupManagementGroup -.-> linux/groups("`Group Displaying`") linux/UserandGroupManagementGroup -.-> linux/groupadd("`Group Adding`") linux/UserandGroupManagementGroup -.-> linux/groupdel("`Group Removing`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") subgraph Lab Skills linux/groups -.-> lab-13397{{"`Groups of Linux`"}} linux/groupadd -.-> lab-13397{{"`Groups of Linux`"}} linux/groupdel -.-> lab-13397{{"`Groups of Linux`"}} linux/sudo -.-> lab-13397{{"`Groups of Linux`"}} end

Understanding Linux Groups

The groups command displays the groups that a user belongs to. This command can be useful for troubleshooting permission issues and verifying that a user has the correct group memberships.

To use the groups command, simply type the following into the terminal:

groups johndoe

This should display the groups that the johndoe user belongs to.

Creating Groups

The groupadd command is used to create a new group on a Linux system. This command requires root privileges, so you will need to use sudo to run it.

To create a new group, type the following into the terminal:

sudo groupadd devs

This will create a new group named devs.

Deleting Groups

The groupdel command is used to delete a group from a Linux system. Like groupadd, this command requires root privileges.

To delete the devs group, type the following into the terminal:

sudo groupdel devs

This will delete the devs group from the system.

Summary

Congratulations, you have completed the lab on Groups of Linux. You should now have a good understanding of how to manage groups on a Linux system, including how to create new groups, add users to groups, and delete existing groups.

Remember to always use caution when making changes to the system, especially when working with user and group permissions. With great power comes great responsibility!

Other Linux Tutorials you may like