Red Hat System Administration I
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.
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
serverbas thestudentuser.Identify and terminate the process that currently uses the most CPU time.
Create the
databasegroup with a GID of 50000.Create the
dbadmin1user and configure it with the following requirements:Add the
databasegroup as a supplementary group.Set the password to
redhatand 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
sudocommand to run any command as the superuser.Configure the default umask as 007 for the
dbadmin1user.
Create the
/home/dbadmin1/grading/review2directory withdbadmin1as the owning user and thedatabasegroup as the owning group.Configure the
/home/dbadmin1/grading/review2directory so that thedatabasegroup 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 thedatabasegroup 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/review2directory.
Log in to
serverbas thestudentuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$Identify and terminate the process that currently uses the most CPU time.
Use the
topcommand to view the real-time system CPU consumption.[student@serverb ~]$
topFrom the interactive interface of the
topcommand, look at the%CPUcolumn and confirm that addprocess is consuming the most CPU resources....output omitted... PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2303student 20 0 217048 944 876 R99.70.1 100:11.64dd...output omitted...The
ddprocess 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.From the interactive interface of the
topcommand, type k to kill theddprocess with the 2303 PID, as you determined in the preceding step. After you type k in thetopcommand, 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...Use the default
SIGTERMsignal to terminate the process....output omitted... Send pid 2833 signal [15/sigterm]
Enter...output omitted...Press the q key to quit the interactive interface of the
topcommand.
Create the
databasegroup with a GID of 50000.Switch to the
rootuser.[student@serverb ~]$
sudo -i[sudo] password for student:student[root@serverb ~]#Create the
databasegroup with a GID of 50000.[root@serverb ~]#
groupadd -g 50000 database
Create the
dbadmin1user. Add thedatabasegroup as a supplementary group. Set the password toredhatand 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 thesudocommand to run any command as the superuser. Configure the default umask as007.Create the
dbadmin1user. Add thedatabasegroup as a supplementary group.[root@serverb ~]#
useradd -G database dbadmin1Set the password of the
dbadmin1user toredhat.[root@serverb ~]#
passwd dbadmin1Changing password for user dbadmin1. New password:redhatBAD PASSWORD: The password is shorter than 8 characters Retype new password:redhatpasswd: all authentication tokens updated successfully.Force the
dbadmin1user to change its password on the next login.[root@serverb ~]#
chage -d 0 dbadmin1Set the password's minimum age of the
dbadmin1user to10days.[root@serverb ~]#
chage -m 10 dbadmin1Set the password's maximum age of the
dbadmin1user to30days.[root@serverb ~]#
chage -M 30 dbadmin1Enable the
dbadmin1user to use thesudocommand to run any command as the superuser. Use thevim /etc/sudoers.d/dbadmin1command to create the file and add the following content:[root@serverb ~]#
vim /etc/sudoers.d/dbadmin1dbadmin1 ALL=(ALL) ALLSwitch to the
dbadmin1user. Append theumask 007line to the/home/dbadmin1/.bashrcfile.[root@serverb ~]#
su - dbadmin1[dbadmin1@serverb ~]$echo "umask 007" >> .bashrcSource the
~/.bashrcfile to update the umask.[dbadmin1@serverb ~]$
source ~/.bashrc
Create the
/home/dbadmin1/grading/review2directory withdbadmin1as the owning user and thedatabasegroup as the owning group.Use the
mkdircommand-poption to create the/home/dbadmin1/grading/review2directory.[dbadmin1@serverb ~]$
mkdir -p /home/dbadmin1/grading/review2Recursively set
dbadmin1anddatabaseas the respective owning user and group of the/home/dbadmin1/directory and subdirectories.[dbadmin1@serverb ~]$
chown -R dbadmin1:database /home/dbadmin1/Recursively set group
executepermissions on the/home/dbadmin1directory and subdirectories. This permission allow members of thedatabasegroup to traverse the/home/dbadmin1directory structure.[dbadmin1@serverb ~]$
chmod -R g+x /home/dbadmin1
Configure the
/home/dbadmin1/grading/review2directory to allow members of thedatabasegroup to create contents in it. All other users should have read and execute permissions on the directory.Apply the SetGID special permission on the
/home/dbadmin1/grading/review2directory so that thedatabasegroup owns files that are created in the directory.[dbadmin1@serverb ~]$
chmod g+s /home/dbadmin1/grading/review2Apply the
775permission mode on the/home/dbadmin1/grading/review2directory.[dbadmin1@serverb ~]$
chmod 775 /home/dbadmin1/grading/review2
Ensure that users are allowed to delete only files that they own from the
/home/dbadmin1/grading/review2directory.Apply the sticky bit special permission on the
/home/dbadmin1/grading/review2directory.[dbadmin1@serverb ~]$
chmod o+t /home/dbadmin1/grading/review2Return to the
workstationsystem as thestudentuser.[dbadmin1@serverb ~]$
exitlogout [root@serverb ~]#exitlogout [student@serverb ~]$exitlogout Connection to serverb closed.