Add New User and Group

LinuxLinuxBeginner
Practice Now

Introduction

The LabEx R&D Team has one server where each team member has an account for daily routine jobs. Today, we have two new employees joining us, and we need to create their accounts.


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/id("`User/Group ID Displaying`") linux/UserandGroupManagementGroup -.-> linux/useradd("`User Adding`") linux/UserandGroupManagementGroup -.-> linux/usermod("`User Modifying`") linux/UserandGroupManagementGroup -.-> linux/passwd("`Password Changing`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") subgraph Lab Skills linux/groups -.-> lab-17987{{"`Add New User and Group`"}} linux/groupadd -.-> lab-17987{{"`Add New User and Group`"}} linux/id -.-> lab-17987{{"`Add New User and Group`"}} linux/useradd -.-> lab-17987{{"`Add New User and Group`"}} linux/usermod -.-> lab-17987{{"`Add New User and Group`"}} linux/passwd -.-> lab-17987{{"`Add New User and Group`"}} linux/sudo -.-> lab-17987{{"`Add New User and Group`"}} end

Add New Users and Groups

In this challenge, you need to add two new users and two new groups to the system.

Tasks

  1. Create new groups named dev and test.
  2. Add a new user account named jack with a home directory of /home/jack and a primary group named dev.
  3. Add a new user account named bob with a home directory of /home/bob and a primary group named test.
  4. Add both jack and bob users to the labex group.

Requirements

  • Use the labex user, which has sudo privileges and belongs to the labex user group, to perform these tasks.
  • Ensure that the new groups dev and test are created before adding the users.
  • Ensure that the new users are created with their respective home directories and primary groups.
  • Verify that both new users are added to the labex group as a secondary group.

Examples

After completing the tasks, you should be able to verify the results as follows:

  1. For user jack, the output similar to the following:
$ id jack
uid=5001(jack) gid=5003(dev) groups=5003(dev),5000(labex)
  1. For user bob, the output similar to the following:
$ id bob
uid=5002(bob) gid=5004(test) groups=5004(test),5000(labex)

Summary

In this challenge, you learned how to add new groups and users to your system. You practiced creating groups, creating user accounts with specific home directories and primary groups, and adding users to additional groups. These skills are essential for user management in Linux systems, particularly when onboarding new team members or managing access control.

Other Linux Tutorials you may like