Creating Users and Groups and Managing User Accounts

Hands-On Lab

 

Photo of Terrence Cox

Terrence Cox

Senior Vice President of Content

Length

01:00:00

Difficulty

Beginner

The ability to manage user accounts and group membership is a crucial part of any system administrator's toolkit. In this hands-on lab, you will work with tools like adduser, useradd, passwd, usermod, groupadd, and groupmod. At the end of this hands-on lab, you will have learned how to use these tools to manage user accounts and groups on any Linux system.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Creating Users and Groups and Managing User Accounts

Introduction

The ability to manage user accounts and group membership is a crucial part of any system administrator's toolkit. In this hands-on lab, you will work with tools like adduser, useradd, passwd, usermod, groupadd, and groupmod. At the end of this hands-on lab, you will have learned how to use these tools to manage user accounts and groups on any Linux system.

Connecting to the Lab

  1. From your terminal application, log in to the cloud server.
    ssh cloud_user@<PUBLIC_IP>
  2. Type yes at the prompt.
  3. Enter your password at the prompt.
  4. Install the nano text editor.
    yum install -y nano

Create a Shared Directory Called /test_scripts

  1. Create a new directory called /test_scripts.

    sudo mkdir test_scripts
  2. Enter your password at the prompt.

  3. List the contents of the directory.

    ls -la

Set the Group Ownership and Permissions

  1. Grant full rights to the owner and group and no rights for anyone else.
    sudo chmod 770 test_scripts/
  2. List the contents of the directory.
    ls -la
  3. Change the group ownership of the test_scripts directory to the testers group.
    sudo chgrp testers test_scripts/

Add the New Users to the System

  1. Change to the home directory.

    cd /home
  2. Add the user tkirk.

    sudo adduser tkirk
  3. Verify that the tkirk directory was created.

    ls -la
  4. Check the contents of the tkirk directory.

    sudo ls -la tkirk/
  5. Add the users nsingh, lpicard, and jarcher.

    sudo adduser nsingh
    sudo adduser lpicard
    sudo adduser jarcher
  6. Verify that this was successful.

    ls -la

Add the New Users to a Group

  1. Add the users to the /etc/group file.
    sudo nano /etc/group
  2. In the nano text editor, locate the line testers:x:1002:.
  3. Add tkirk, nsingh, lpicard, jarcher to the end of the line:
    testers:x:1002:tkirk,nsingh,lpicard,jarcher
  4. Press Ctrl + X to quit the nano text editor.
  5. Press Y then Enter to save the changes.
  6. Switch to the nsingh user
    sudo su nsingh
  7. Change to the /test_scripts/ directory.
    cd /test_scripts
  8. List the contents of the directory.
    ls -la
  9. Create a new test file.
    touch test.txt
  10. Verify that the new file was created.
    ls -la
  11. Switch to the kjaneway user.
    exit
    sudo su kjaneway
  12. Change to the root directory.
    cd /
  13. List the contents of the directory.
    ls -la
  14. Change to the test_scripts directory.
    cd test_scripts/
  15. You should receive a "Permission denied" message.

Conclusion

Congratulations, you've successfully completed this hands-on lab!