Bookmark this page

Guided Exercise: Manage Local User Accounts

Create several users on your system and set passwords for those users.

Outcomes

  • Configure a Linux system with additional user accounts.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start users-user

Instructions

  1. From workstation, open an SSH session to servera as the student user, and switch to the root user.

    [student@workstation ~]$ ssh student@servera
    ...output omitted...
    [student@servera ~]$ sudo -i
    [sudo] password for student: student
    [root@servera ~]#
  2. Create the operator1 user and confirm that it exists in the system.

    [root@servera ~]# useradd operator1
    [root@servera ~]# tail /etc/passwd
    ...output omitted...
    operator1:x:1002:1002::/home/operator1:/bin/bash
  3. Set the password for operator1 to redhat.

    [root@servera ~]# passwd operator1
    Changing password for user operator1.
    New password: redhat
    BAD PASSWORD: The password is shorter than 8 characters
    Retype new password: redhat
    passwd: all authentication tokens updated successfully.
  4. Create the additional operator2 and operator3 users. Set their passwords to redhat.

    1. Add the operator2 user. Set the password for operator2 to redhat.

      [root@servera ~]# useradd operator2
      [root@servera ~]# passwd operator2
      Changing password for user operator2.
      New password: redhat
      BAD PASSWORD: The password is shorter than 8 characters
      Retype new password: redhat
      passwd: all authentication tokens updated successfully.
    2. Add the operator3 user. Set the password for operator3 to redhat.

      [root@servera ~]# useradd operator3
      [root@servera ~]# passwd operator3
      Changing password for user operator3.
      New password: redhat
      BAD PASSWORD: The password is shorter than 8 characters
      Retype new password: redhat
      passwd: all authentication tokens updated successfully.
  5. Update the operator1 and operator2 user accounts to include the Operator One and Operator Two comments, respectively. Verify that the comments exist for the user accounts.

    1. Run the usermod -c command to update the comments of the operator1 user account.

      [root@servera ~]# usermod -c "Operator One" operator1
    2. Run the usermod -c command to update the comments of the operator2 user account.

      [root@servera ~]# usermod -c "Operator Two" operator2
    3. View the /etc/passwd file to confirm that the comments for each of the operator1 and operator2 users exist.

      [root@servera ~]# tail /etc/passwd
      ...output omitted...
      operator1:x:1002:1002:Operator One:/home/operator1:/bin/bash
      operator2:x:1003:1003:Operator Two:/home/operator2:/bin/bash
      operator3:x:1004:1004::/home/operator3:/bin/bash
  6. Delete the operator3 user along with any personal data of the user. Confirm that the operator3 does not exist.

    1. Remove the operator3 user from the system.

      [root@servera ~]# userdel -r operator3
    2. Confirm that the operator3 user does not exist.

      [root@servera ~]# tail /etc/passwd
      ...output omitted...
      operator1:x:1002:1002:Operator One:/home/operator1:/bin/bash
      operator2:x:1003:1003:Operator Two:/home/operator2:/bin/bash

      Notice that the preceding output does not display the user account information of operator3.

    3. Confirm that the operator3 user home directory does not exist.

      [root@servera ~]# ls -l /home
      total 0
      drwx------. 4 devops    devops    90 Mar  3 09:59 devops
      drwx------. 2 operator1 operator1 62 Mar  9 10:19 operator1
      drwx------. 2 operator2 operator2 62 Mar  9 10:19 operator2
      drwx------. 3 student   student   95 Mar  3 09:49 student
    4. Exit the root user's shell to return to the student user's shell.

      [root@servera ~]# exit
      logout
      [student@servera ~]$
    5. Log off from the servera machine.

      [student@servera ~]$ exit
      logout
      Connection to servera closed.
      [student@workstation ~]$

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish users-user

Revision: rh124-9.3-770cc61