Create and Manage Local User Accounts

LinuxLinuxBeginner
Practice Now

Introduction

As a Linux system administrator, managing user accounts is a critical task. In this challenge, you will learn how to create, delete, and modify local user accounts on a Linux system. You will also learn how to set user passwords and manage user groups.


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-389447{{"`Create and Manage Local User Accounts`"}} end

Create a New User Account

Tasks

  • Create a new user account named john with the default shell set to /bin/bash.
  • Set the user's password to password123.

Requirements

  • The new user account should be created in the default home directory /home/john.
  • The user account should be created using the useradd command.
  • The user's password should be set using the passwd command.

Example

After completing this step, you should be able to log in to the system using the john account with the password password123.

Modify an Existing User Account

Tasks

  • Change the user's default shell to /bin/zsh.
  • Add the john user to the wheel group.

Requirements

  • The user's default shell should be changed using the usermod command.
  • The user should be added to the wheel group using the usermod command.

Example

After completing this step, the john user should be able to log in with the /bin/zsh shell and have access to the wheel group.

Delete a User Account

Tasks

  • Delete the john user account.

Requirements

  • The user account should be deleted using the userdel command.
  • All files and directories associated with the john user account should be removed.

Example

After completing this step, the john user account should no longer exist on the system.

Summary

In this challenge, you learned how to create, modify, and delete local user accounts on a Linux system. You also learned how to set user passwords and manage user group memberships. These skills are essential for Linux system administrators who need to manage user accounts and access control on their systems.

To set up the initial environment for this challenge, you can run the following setup.sh script:

#!/bin/bash

## Create the 'john' user account
sudo useradd -m -s /bin/bash john
sudo passwd john

## Add the 'john' user to the 'wheel' group
sudo usermod -aG wheel john

This script will create the john user account with the default shell set to /bin/bash and add the user to the wheel group. You can then proceed with the challenge steps to modify and delete the user account.

Other Linux Tutorials you may like