Log in and Switch Users

LinuxLinuxBeginner
Practice Now

Introduction

In Linux systems, it's common to have multiple users sharing the same environment. As a system administrator, you need to be proficient in managing user accounts and switching between them. This challenge will test your skills in user management and authentication in a Linux environment.

Environment

LabEx uses Red Hat Universal Base Image 9 (UBI9) to simulate the exam environment. It may not be identical to the actual RHCSA exam environment, but it provides a good representation of the tasks you'll encounter.

There are two users in the environment:

  • labex: A standard user with sudo privileges, password: labex.
  • root: The system administrator, password: redhat.

The challenge features real exam questions, along with explanations, requirements, and automated verification scripts to help you confirm task completion. It effectively simulates the knowledge areas covered in the RHCSA exam.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/BasicSystemCommandsGroup -.-> linux/exit("`Shell Exiting`") linux/UserandGroupManagementGroup -.-> linux/whoami("`User Identifying`") linux/UserandGroupManagementGroup -.-> linux/useradd("`User Adding`") linux/UserandGroupManagementGroup -.-> linux/passwd("`Password Changing`") linux/UserandGroupManagementGroup -.-> linux/su("`User Switching`") subgraph Lab Skills linux/exit -.-> lab-389335{{"`Log in and Switch Users`"}} linux/whoami -.-> lab-389335{{"`Log in and Switch Users`"}} linux/useradd -.-> lab-389335{{"`Log in and Switch Users`"}} linux/passwd -.-> lab-389335{{"`Log in and Switch Users`"}} linux/su -.-> lab-389335{{"`Log in and Switch Users`"}} end

Switch Users and Create a New Account

This step will guide you through the process of switching between users and creating a new user account.

Tasks

  • Switch to the root user using sudo
  • Create a new user named projectuser
  • Switch to the projectuser account
  • Return to the labex user account

Requirements

  • You are already logged in as the labex user
  • All operations should be performed in the terminal
  • Use the sudo command to switch to the root user
  • Create the projectuser with a home directory in /home/projectuser
  • Set the password for projectuser to project123
  • Use the su command to switch between users
  • Ensure you end up logged in as the labex user

Example

After completing the tasks, you should be able to see the following output when running the who command:

labex    pts/0        2023-08-28 10:00 (:0)

Summary

In this challenge, you practiced essential user management skills in a Linux environment. You learned how to switch between users using sudo and su commands, create a new user account with a specified home directory, and set user passwords. These skills are crucial for system administrators managing multi-user systems, ensuring proper user isolation, and maintaining system security.

Other Linux Tutorials you may like