Bookmark this page

Lab: Manage Users and Groups, Permissions, and Processes

Note

If you plan to take the RHCSA exam, then use the following approach to maximize the benefit of this Comprehensive Review: attempt each lab without viewing the solution buttons or referring to the course content. Use the grading scripts to gauge your progress as you complete each lab.

In this review, you manage user and group accounts, set permissions on files and directories, and manage processes.

Outcomes

  • Manage user accounts and groups.

  • Set permissions on files and directories.

  • Identify and manage high CPU-consuming processes.

If you did not reset your workstation and server machines at the end of the last chapter, then save any work that you want to keep from earlier exercises on those machines, and reset them now.

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 rhcsa-rh124-review2

Specifications

  • Log in to serverb as the student user.

  • Identify and terminate the process that currently uses the most CPU time.

  • Create the database group with a GID of 50000.

  • Create the dbadmin1 user and configure it with the following requirements:

    • Add the database group as a supplementary group.

    • Set the password to redhat and force a password change on first login.

    • Allow the password to change after 10 days since the day of the last password change.

    • Set the password expiration to 30 days since the day of the last password change.

    • Allow the user to use the sudo command to run any command as the superuser.

    • Configure the default umask as 007 for the dbadmin user.

  • Create the /home/dbadmin1/grading/review2 directory with dbadmin1 as the owning user and the database group as the owning group.

  • Configure the /home/dbadmin1/grading/review2 directory so that the database group owns any file or sub-directory that is created in this directory, irrespective of which user created the file. Configure the permissions on the directory to allow members of the database group to access the directory and to create contents in it. All other users should have read and execute permissions on the directory.

  • Ensure that users are allowed to delete only files that they own from the /home/dbadmin1/grading/review2 directory.

  1. Log in to serverb as the student user.

    [student@workstation ~]$ ssh student@serverb
    ...output omitted...
    [student@serverb ~]$
  2. Identify and terminate the process that currently uses the most CPU time.

    1. Use the top command to view the real-time system CPU consumption.

      [student@serverb ~]$ top
    2. From the interactive interface of the top command, look at the %CPU column and confirm that a dd process is consuming the most CPU resources.

      ...output omitted...
      PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
      2303 student   20   0  217048    944    876 R  99.7   0.1 100:11.64 dd
      ...output omitted...

      The dd process in the preceding output has the 2303 PID. This process is consuming 99.7% of the CPU resources. The PID and the percentage of CPU resource consumption would vary in your system.

    3. From the interactive interface of the top command, type k to kill the dd process with the 2303 PID, as you determined in the preceding step. After you type k in the top command, if the default PID that is shown in the prompt matches the PID of the process to terminate, then press the Enter key. If the suggested PID does not match, then specify the PID interactively.

      ...output omitted...
      PID to signal/kill [default pid = 2303] Enter
      ...output omitted...
    4. Use the default SIGTERM signal to terminate the process.

      ...output omitted...
      Send pid 2833 signal [15/sigterm] Enter
      ...output omitted...
    5. Press the q key to quit the interactive interface of the top command.

  3. Create the database group with a GID of 50000.

    1. Switch to the root user.

      [student@serverb ~]$ sudo -i
      [sudo] password for student: student
      [root@serverb ~]#
    2. Create the database group with a GID of 50000.

      [root@serverb ~]# groupadd -g 50000 database
  4. Create the dbadmin1 user. Add the database group as a supplementary group. Set the password to redhat and force a password change on the user's first login. Allow the password to change after 10 days since the day of the last password change. Set the password expiration to 30 days since the day of the last password change. Allow the user to use the sudo command to run any command as the superuser. Configure the default umask as 007.

    1. Create the dbadmin1 user. Add the database group as a supplementary group.

      [root@serverb ~]# useradd -G database dbadmin1
    2. Set the password of the dbadmin1 user to redhat.

      [root@serverb ~]# passwd dbadmin1
      Changing password for user dbadmin1.
      New password: redhat
      BAD PASSWORD: The password is shorter than 8 characters
      Retype new password: redhat
      passwd: all authentication tokens updated successfully.
    3. Force the dbadmin1 user to change its password on the next login.

      [root@serverb ~]# chage -d 0 dbadmin1
    4. Set the password's minimum age of the dbadmin1 user to 10 days.

      [root@serverb ~]# chage -m 10 dbadmin1
    5. Set the password's maximum age of the dbadmin1 user to 30 days.

      [root@serverb ~]# chage -M 30 dbadmin1
    6. Enable the dbadmin1 user to use the sudo command to run any command as the superuser. Use the vim /etc/sudoers.d/dbadmin1 command to create the file and add the following content:

      [root@serverb ~]# vim /etc/sudoers.d/dbadmin1
      dbadmin1 ALL=(ALL) ALL
    7. Switch to the dbadmin1 user. Append the umask 007 line to the /home/dbadmin1/.bashrc file.

      [root@serverb ~]# su - dbadmin1
      [dbadmin1@serverb ~]$ echo "umask 007" >> .bashrc
    8. Source the ~/.bashrc file to update the umask.

      [dbadmin1@serverb ~]$ source ~/.bashrc
  5. Create the /home/dbadmin1/grading/review2 directory with dbadmin1 as the owning user and the database group as the owning group.

    1. Use the mkdir command -p option to create the /home/dbadmin1/grading/review2 directory.

      [dbadmin1@serverb ~]$ mkdir -p /home/dbadmin1/grading/review2
    2. Recursively set dbadmin1 and database as the respective owning user and group of the /home/dbadmin1/ directory and subdirectories.

      [dbadmin1@serverb ~]$ chown -R dbadmin1:database /home/dbadmin1/
    3. Recursively set group execute permissions on the /home/dbadmin1 directory and subdirectories. This permission allow members of the database group to traverse the /home/dbadmin1 directory structure.

      [dbadmin1@serverb ~]$ chmod -R g+x /home/dbadmin1
  6. Configure the /home/dbadmin1/grading/review2 directory to allow members of the database group to create contents in it. All other users should have read and execute permissions on the directory.

    1. Apply the SetGID special permission on the /home/dbadmin1/grading/review2 directory so that the database group owns files that are created in the directory.

      [dbadmin1@serverb ~]$ chmod g+s /home/dbadmin1/grading/review2
    2. Apply the 775 permission mode on the /home/dbadmin1/grading/review2 directory.

      [dbadmin1@serverb ~]$ chmod 775 /home/dbadmin1/grading/review2
  7. Ensure that users are allowed to delete only files that they own from the /home/dbadmin1/grading/review2 directory.

    1. Apply the sticky bit special permission on the /home/dbadmin1/grading/review2 directory.

      [dbadmin1@serverb ~]$ chmod o+t /home/dbadmin1/grading/review2
    2. Return to the workstation system as the student user.

      [dbadmin1@serverb ~]$ exit
      logout
      [root@serverb ~]# exit
      logout
      [student@serverb ~]$ exit
      logout
      Connection to serverb closed.

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade rhcsa-rh124-review2

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 rhcsa-rh124-review2

This concludes the section.

Revision: rh124-9.0-398f302