Book tasks:
Instructions:
Display the current time and date: Use the
datecommand to display the current time and date.Display current time in 24-hour clock format: Use the format string
%Rwith thedatecommand to display the time in 24-hour format (e.g., 13:57).Check the file type of
/home/student/zcat: Determine the type of file/home/student/zcatis and whether it is human-readable.Check the size of
zcat: Use thewccommand and Bash shortcuts to display the size of thezcatfile.Display the first 10 lines of the
zcatfile: Use the appropriate command to show the first 10 lines of the file.Display the last 10 lines of the
zcatfile: Use the command to display the last 10 lines of thezcatfile.Repeat the previous command with minimal keystrokes: Repeat the previous step with four or fewer keystrokes using a shortcut.
Display the last 20 lines of the
zcatfile: Use thetailcommand with the-n 20option to display the last 20 lines of the file.Run the
datecommand again using shell history: Use the shell history to run thedate +%Rcommand again.
Instructions
Use the
sshcommand to log in to theserverbmachine as thestudentuser. The system's configuration supports the use of SSH keys for authentication.Create a directory called
project_plansin theDocumentsdirectory. TheDocumentsdirectory should be placed in thestudentuser's home directory. Create two empty files in theproject_plansdirectory calledseason1_project_plan.odfandseason2_project_plan.odf. Hint: If the~/Documentsdirectory does not exist, then use themkdir -poption to create it.Create sets of empty practice files to use in this lab. If you do not immediately recognize the intended shell expansion shortcut, then use the solution to learn and practice.
Use shell tab completion to locate file path names easily. Create 12 files with names
tv_seasonX_episodeY.oggin the/home/studentdirectory. ReplaceXwith the season number andYwith that season's episode, for two seasons of six episodes each.As the author of a successful series of mystery novels, you are editing your next bestseller's chapters for publishing. Create eight files with names
mystery_chapterX.odf. ReplaceXwith the numbers 1 through 8.Use a single command to create two subdirectories called
season1andseason2under theVideosdirectory to organize the TV episodes. Move the appropriate TV episodes into the season subdirectories. Use only two commands, and specify destinations with relative syntax.Create a two-level directory hierarchy with a single command to organize the mystery book chapters. Create the
my_bestsellersubdirectory under theDocumentsdirectory, and thechapterssubdirectory under the newmy_bestsellerdirectory. Create three more subdirectories directly under themy_bestsellerdirectory with a single command. Name these subdirectorieseditor,changes, andvacation. You do not need to use themkdir -pcommand to create parents because themy_bestsellerparent directory exists.Change to the
chaptersdirectory. Use the tilde (~) home directory shortcut to move all book chapters to thechaptersdirectory, which is now your current directory. Use the simplest syntax to specify the destination directory.You want to send the first two chapters to the editor for review. Move only those two chapters to the
editordirectory to avoid modifying them during the review. Starting from thechapterssubdirectory, use brace expansion with a range to specify the chapter file names to move and a relative path for the destination directory.While on vacation, you intend to write chapters 7 and 8. Use a single command to move the files from the
chaptersdirectory to thevacationdirectory. Specify the chapter file names by using brace expansion with a list of strings and without using wildcard characters.Change your working directory to
~/Videos/season2, and then copy the first episode of the season to thevacationdirectory. Use a singlecdcommand to change from your working directory to the~/Documents/my_bestseller/vacationdirectory. List its files. Use the previous working directory argument to return to theseason2directory. (This argument succeeds if the last directory change with thecdcommand used one command rather than severalcdcommands.) From theseason2directory, copy the episode 2 file into thevacationdirectory. Use the shortcut again to return to thevacationdirectory.The authors of chapters 5 and 6 want to experiment with possible changes. Copy both files from the
~/Documents/my_bestseller/chaptersdirectory to the~/Documents/my_bestseller/changesdirectory to prevent these changes from modifying original files.Navigate to the
~/Documents/my_bestsellerdirectory. Use square-bracket pattern matching to specify which chapter numbers to match in the filename argument of thecpcommand.Change your current directory to the
changesdirectory and use thedate +%Fcommand with command substitution to copymystery_chapter5.odfto a new file that includes the full date. Use themystery_chapter5_YYYY-MM-DD.odfname format.By using command substitution with the
date +%scommand, make another copy ofmystery_chapter5.odf, and append the current time stamp (as the number of seconds since the epoch, 1970-01-01 00:00 UTC) to ensure a unique file name.After further review, you decide that you do not need the plot changes. Delete the
changesdirectory.If it is necessary, then navigate to the
changesdirectory and delete all the files within the directory. You cannot delete a directory while it is the current working directory.Change to the parent directory of the
changesdirectory. Try to delete the empty directory by using thermcommand without the-rrecursive option. This attempt should fail. Finally, use thermdircommand to delete the empty directory, which succeeds.When the vacation is over, you no longer need the
vacationdirectory. Delete it by using thermcommand with the recursive option.When finished, return to the student user's home directory.
Create a hard link to the
~/Documents/project_plans/season2_project_plan.odffile called~/Documents/backups/season2_project_plan.odf.back. A hard link protects against accidental deletion of the original file and keeps the backup file updated as you change the original file. Hint: If the~/Documents/backupsdirectory does not exist, then use themkdircommand to create it.
Instructions
On the workstation machine, determine how to prepare a man page for printing. Specifically, find which is the default format or rendering language for printing.
Create a PostScript formatted output file of the passwd man page. Call the file
passwd.psand place it in the student user's home directory. Determine the file content format. Inspect the contents of thepasswd.psfile by using thelesscommand. Note: As you need to save the output of the man command to a file, you can use the>symbol, which redirects the standard output to a file. As an example, the following command lists the home directory's regular file names into a file:bashCopy code[student@workstation ~]$ ls > /tmp/my-file-namesThis command is taught in more detail in a following chapter.
By using the man pages, find which commands you can use for viewing and printing PostScript files.
Learn how to use the
evince(1)viewer in preview mode. Also, determine how to open a document to start on a specific page. Open your PostScript file by usingevincethree times:First by using the default mode,
Then with the preview mode option,
And finally to start at page 3. Close your document file when you finish.
By using the man pages, research
lp(1)to determine how to print any document to start on a specific page.Without entering any commands (in the absence of printers), learn the syntax, in one command, to print only pages 2 and 3 of your PostScript file.
Use the Firefox browser to open the system's man page directory (
/usr/share/doc) and browse into the man-db package subdirectory.View the provided manuals. After you finish reviewing the man-db manuals, locate and browse to the
kexec-toolspackage subdirectory. View thekexec-kdump-howto.txtfile, which describes important system configuration options that are stored in the/etc/sysconfigdirectory.
Instructions
On workstation, create the
lab_fileshell variable and assignediting_final_lab.txtas the value.List the student home directory, including hidden directories and files, and redirect the output to the
editing_final_lab.txtfile by using the shell variable.Use Vim to edit the
editing_final_lab.txtfile. Use thelab_fileshell variable.Enter the line-based visual mode of Vim. Your screen output may be different than these examples. Remove the first three lines of the
editing_final_lab.txtfile.Enter the visual mode of Vim. Remove the last seven characters from the first column on the first line. Preserve only the first four characters of the first column.
Use the arrow keys to position the cursor at the last character of the first column on the first line. Delete the selection by typing
x.Enter the visual block mode of Vim. Repeat the operation of the previous step, but this time select from the second to the last line. Preserve only the first four characters of the first column.
Enter the visual block mode of Vim and remove the fourth column of the file.
Enter the visual block mode of Vim to remove the time column, leaving the month and day columns on all lines.
Enter the visual line mode of Vim and remove the rows that contain the
DesktopandPublicstrings.Save your changes and exit the file.
Back up the
editing_final_lab.txtfile and append the date (in seconds) at the end of the file name preceded with an underscore (_) character. Use thelab_fileshell variable.Append a dashed line to the
editing_final_lab.txtfile. The dashed line should contain 12 dash (-) characters for this lab to be graded correctly. Use thelab_fileshell variable.List the content of the
Documentdirectory and redirect the output to theediting_final_lab.txtfile. Use thelab_fileshell variable.Confirm that the directory listing is at the bottom of the lab file. Use the
lab_fileshell variable.
Instructions
From the workstation machine, open an SSH session to the
serverbmachine as thestudentuser and switch to the root user.On the
serverbmachine, ensure that newly created users must change their passwords every 30 days.Create the
consultantsgroup with a GID of 35000.Configure administrative rights to enable all
consultantsgroup members to execute any command as any user.Create the
consultant1,consultant2, andconsultant3users with theconsultantsgroup as their secondary group.Set the
consultant1,consultant2, andconsultant3passwords toredhat.Set the
consultant1,consultant2, andconsultant3accounts to expire in 90 days from the current day.Change the password policy for the
consultant2account to require a new password every 15 days.Additionally, force the
consultant1,consultant2, andconsultant3users to change their passwords on the first login.
Instructions
Log in to
serverbas thestudentuser. Switch to the root user, and useredhatas the password.Create a
/home/techdocsdirectory.Change the group ownership of the
/home/techdocsdirectory to thetechdocsgroup.Verify that users in the
techdocsgroup cannot create files in the/home/techdocsdirectory.Set permissions on the
/home/techdocsdirectory. On the/home/techdocsdirectory, configure:setgid (2),
read, write, and execute permissions (7) for the owner/user and group,
no permissions (0) for other users.
Verify that the permissions are set properly.
The
techdocsgroup now has write permission.Confirm that users in the
techdocsgroup can now create and edit files in the/home/techdocsdirectory. Users that are not in thetechdocsgroup cannot edit or create files in the/home/techdocsdirectory. Thetech1andtech2users are in thetechdocsgroup. Thedatabase1user is not in that group.Modify the global login scripts. Normal users should have a
umasksetting that allows the user and group to create, write, and execute files and directories, while preventing other users from viewing, modifying, or executing new files and directories.
Instructions
On workstation, open two terminal windows side by side. In this section, these terminals are referred to as left and right. On each terminal window, log in to
serverbas thestudentuser. Create theprocess101script in the/home/student/bindirectory. Theprocess101script generates artificial CPU load:bashCopy code#!/bin/bash while true; do var=1 while [[ var -lt 50000 ]]; do var=$(($var+1)) done sleep 1 doneIn the right terminal shell, run the
toputility.In the left terminal shell, verify the number of logical CPUs on the virtual machine. Run the
process101script in the background.In the right terminal shell, observe the
topdisplay. Note the process ID (PID) and view the CPU percentage that theprocess101process uses. The CPU percentage that the process uses should hover around 10% to 15%. Toggle thetoputility display between load, threads, and memory. Return to the CPU usage display of thetoputility.Turn off the use of bold in the display. Save this configuration for reuse when
topis restarted. Confirm that the changes are saved.Copy the
process101script to a newprocess102file, and increase the artificial CPU load to one hundred thousand in the new script. Start theprocess102process in the background.In the right terminal shell, verify that the
process102is running and uses the most CPU resources. The load should hover between 25% and 35%.Notice that the load average is below 1. Copy the
process101script to a new script calledprocess103. Increase the addition count to eight hundred thousand. Startprocess103in the background. Confirm that the load average is above 1. It may take a few minutes for the load average to change.In the left terminal shell, switch to the root user. Suspend the
process101process. List the remaining jobs. Observe that the process state forprocess101is now in the T state.Resume the
process101process.Terminate
process101,process102, andprocess103from the command line. Verify that the processes are no longer displayed intop.Stop processes and return to the workstation machine.
Instructions
Use the
sshcommand to log in to theserverbmachine as thestudentuser. On theserverbmachine, start thepsacctservice.Configure the
psacctservice to start at system boot.Stop the
rsyslogservice.Configure the
rsyslogservice so that it does not start at system boot.Reboot the
serverbmachine before evaluating the lab.
Instructions
From the workstation machine, log in to the
serveramachine as thestudentuser.Switch to the
production1user on theserveramachine. Enterredhatas the password.Generate passphrase-less SSH keys for the
production1user on theserveramachine.Send the public key of the SSH key pair to the
production1user on theserverbmachine.Verify that the
production1user can successfully log in to theserverbmachine with the SSH keys.Configure the
sshdservice onserverbto prevent users from logging in as the root user. Useredhatas the root password.Configure the
sshdservice on theserverbmachine to allow users to authenticate with SSH keys only, rather than with their passwords.
Instructions
Log in to the
serverbmachine as thestudentuser.Pretend that the
serverbmachine is relocated to Jamaica and that you must update the time zone. Verify that you correctly set the appropriate time zone.View the recorded log events in the previous 30 minutes on the
serverbmachine.Create the
/etc/rsyslog.d/auth-errors.conffile. Configure thersyslogservice to write authentication and security messages to the/var/log/auth-errorsfile. Use theauthprivfacility and thealertpriority.
Instructions
Log in to the
serverbmachine as thestudentuser. Switch to the root user.Create a connection with a static network configuration by using the settings in the table:
ParameterSettingConnection name
lab
Interface name
enX (might vary; use the interface with 52:54:00:00:fa:0b as its MAC address)
IP address
172.25.250.11/24
Gateway address
172.25.250.254
DNS address
172.25.250.254
Configure the new connection to start automatically. Other connections should not start automatically.
Modify the new connection so that it also uses the IP address
10.0.1.1/24.Configure the hosts file so that you can reference the
10.0.1.1IP address with the private name.Reboot the system.
Verify that the
serverbmachine is initialized.
Instructions
On
serverb, synchronize the/etcdirectory tree fromserverato the/configsyncdirectory.Create a
configfile-backup-servera.tar.gzarchive with the/configsyncdirectory contents.Securely copy the
/root/configfile-backup-servera.tar.gzarchive file fromserverbto the/home/studentdirectory onworkstation.On
workstation, extract the contents to the/tmp/savedconfig/directory.
Instructions
On the
serverbmachine, configure a software repository to obtain updates. Name the repositoryerrataand configure the repository in the/etc/yum.repos.d/errata.repofile. Configure theerrata.repofile to use thehttp://content.example.com/rhel9.0/x86_64/rhcsa-practice/erratarepository. Do not check GPG signatures.On
serverb, install therht-systempackage.For security reasons, the
serverbmachine must not be able to connect to a paper printer. You can achieve this effect by removing thecupspackage. When finished, exit from the root shell.The start script downloads the
rhcsa-script-1.0.0-1.noarch.rpmpackage in the/home/studentdirectory on theserverbmachine.Confirm that the
rhcsa-script-1.0.0-1.noarch.rpmpackage is available onserverband install it using root privileges. Verify that the package is installed.Exit from the
serverbmachine.
Instructions
On the
serverbmachine as the root user, identify the UUID for the/dev/vdb1device, and mount it by using its UUID on the/mnt/freespacedirectory.Generate a disk usage report for the
/usr/sharedirectory. Save the result in the/mnt/freespace/results.txtfile.Find all
rsyslog.confconfiguration files and store the result in the/mnt/freespace/search1.txtfile.Store the search result of all files in the
/usr/sharedirectory that are greater than 50 MB and less than 100 MB in the/mnt/freespace/search2.txtfile.Return to the
workstationsystem as thestudentuser.
Instructions
Create the
/home/student/bin/bash-labscript file on theworkstationmachine. The initial content in the script will be the shebang interpreter directive.Edit your newly created script file to comply with the following requested information from the
serveraandserverbhosts. The systems use SSH keys for authentication, and therefore you do not require a password.Command or file
Content requested
hostname -fGet all the output.
echo "#####"Get all the output.
lscpuGet only the lines that start with the string
CPU.echo "#####"Get all the output.
/etc/selinux/configIgnore empty lines. Ignore lines starting with
#.echo "#####"Get all the output.
/var/log/secureGet all "Failed password" entries.
echo "#####"Get all the output.
Save the required information to the
output-serveraandoutput-serverbfiles in the/home/studentdirectory onworkstation.Note: You can use the
sudocommand without requiring a password on theserveraandserverbhosts. Remember to use a loop to simplify your script. You can also use multiplegrepcommands that are concatenated with the use of the pipe character (|).Execute the
/home/student/bin/bash-labscript, and review the output content onworkstation.
Instructions
Change the current tuning profile for the
serverbmachine to the balanced profile, a general non-specialized tuned profile. List the information for the balanced tuning profile when it is the current tuning profile.Two processes on
serverbare consuming a high percentage of CPU usage. Adjust each process's nice level to 10 to allow more CPU time for other processes.
Instructions
Log in to the
serverbmachine as thestudentuser and switch to the root user.From a web browser on the
workstationmachine, view thehttp://serverb/lab.htmlweb page. You see the error message: "You do not have permission to access this resource."Research and identify the SELinux issue that prevents the Apache service from serving web content.
Display the SELinux context of the new HTTP document directory and the original HTTP document directory.
Resolve the SELinux issue that prevents the Apache server from serving web content.
Verify that the Apache server can now serve web content.
Return to the
workstationmachine as thestudentuser.
Instructions
The
serverbmachine has several unused disks. On the first unused disk, create a 2 GB GPT backup partition. Because it is difficult to set an exact size, a size between 1.8 GB and 2.2 GB is acceptable.Configure the backup partition to host an XFS file system.
Format the 2 GB backup partition with an XFS file system and persistently mount it to the
/backupdirectory.On the same disk, create two 512 MB GPT partitions called
swap1andswap2. A size between 460 MB and 564 MB is acceptable.Configure the file-system types of the partitions to host swap spaces.
Initialize the two 512 MiB partitions as swap spaces and configure them to activate at boot.
Set the swap space on the
swap2partition to be preferred over the other.To verify your work, reboot the
serverbmachine. Confirm that the system automatically mounts the first partition onto the/backupdirectory. Also, confirm that the system activates the two swap spaces.
Instructions
On the serverb machine, the serverb_01_lv logical volume mounted on the /storage/data1 directory is running out of disk space and needs to be extended to 768 MiB. You must ensure that the serverb_01_lv LV remains persistently mounted on the /storage/data1 directory.
The serverb_01_lv LV is present on the serverb_01_vg volume group. Unfortunately, it has insufficient space to extend the existing logical volume. A 512 MiB partition exists on the /dev/vdb disk.
Create a 512 MiB partition on the
/dev/vdbdisk. Initialize this partition as a physical volume, and extend theserverb_01_vgvolume group to use this partition.Extend the
serverb_01_lvlogical volume to 768 MiB.In the existing volume group, create the new
serverb_02_lvlogical volume with 128 MiB. Add an XFS file system and mount it persistently on the/storage/data2directory.Verify that the newly created LV is mounted with the desired size.
Instructions
An IT support company uses a central server, serverb, to host some exported directories on /shares for their groups and users. Users must be able to log in and have their exported directories mounted on demand and ready to use, under the /remote directory on servera.
Environment Characteristics:
The
serverbmachine is sharing the/sharesdirectory, which in turn contains themanagement,production, andoperationsubdirectories.The
managersgroup consists of themanager1andmanager2users. They have read and write access to the/shares/managementexported directory.The
productiongroup consists of thedbuser1andsysadmin1users. They have read and write access to the/shares/productionexported directory.The
operatorsgroup consists of thecontractor1andconsultant1users. They have read and write access to the/shares/operationexported directory.The main mount point for
serverais the/remotedirectory.Use the
/etc/auto.master.d/shares.autofsfile as the master map file and the/etc/auto.sharesfile as the indirect map file.The
/shares/managementexported directory is automounted on/remote/managementonservera.The
/shares/productionexported directory is automounted on/remote/productiononservera.The
/shares/operationexported directory is automounted on/remote/operationonservera.All user passwords are set to
redhat.
Log in to
serveraand install the required packages.Configure an automounter indirect map on
serverawith exports fromserverb. Create an indirect map with files that are named/etc/auto.master.d/shares.autofsfor the master map and/etc/auto.sharesfor the mapping file. Use the/remotedirectory as the main mount point onservera. Rebootserverato determine whether the autofs service starts automatically.Test the autofs configuration with the various users. When done, log out from
servera.
Instructions
On the
serverbmachine, reset the password toredhatfor the root user.Locate the icon for the
serverbmachine console as appropriate for your classroom environment, then open the console.In the boot-loader menu, select the default kernel boot-loader entry. The system fails to boot because a start job does not complete successfully. Fix the issue from the console of the
serverbmachine.Change the default systemd target on the
serverbmachine for the system to automatically start a graphical interface when it boots.No graphical interface is installed on the
serverbmachine. Only set the default target for this exercise and do not install the packages.
Instructions
Your company has decided to run a new web app. This application listens on ports 80/TCP and 1001/TCP. You should also make available port 22/TCP for SSH access. All changes you make should persist across a reboot.
Important:
Red Hat Online Learning environment needs port 5900/TCP to remain available to use the graphical interface. This port is also known under the vnc-server service.
If you accidentally lock yourself out from the serverb machine, you can either attempt to recover by using the ssh command to your serverb machine from your workstation machine, or reset your serverb machine. If you elect to reset your serverb machine, you should run the setup scripts for this lab again. The configuration on your machines already includes a custom zone called ROL that opens these ports.
From the
workstationmachine, test access to the default web server athttp://serverb.lab.example.comand to the virtual host athttp://serverb.lab.example.com:1001.Log in to the
serverbmachine to determine what is preventing access to the web servers.Configure SELinux to allow the
httpdservice to listen on port 1001/TCP.From
workstation, test again access to the default web server athttp://serverb.lab.example.comand to the virtual host athttp://serverb.lab.example.com:1001.Log in to the
serverbmachine to determine whether the correct ports are assigned to the firewall.Add port 1001/TCP to the permanent configuration for the public network zone. Confirm your configuration.
From
workstation, confirm that the default web server atserverb.lab.example.comand the virtual host atserverb.lab.example.com:1001returnsSERVER VHOST 1.
Instructions
Prepare a kickstart file on the serverb machine as specified and make it available at the http://serverb.lab.example.com/ks-config/kickstart.cfg address.
On the
serverbmachine, copy the/root/anaconda-ks.cfgkickstart file to the/home/student/kickstart.cfgkickstart file for making it editable for thestudentuser.Make changes to the
/home/student/kickstart.cfgkickstart file:Comment out the
rebootcommand.Modify the
repocommand for the BaseOS and AppStream repositories. Modify therepocommand for the BaseOS repository to use thehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/BaseOS/address. Modify therepocommand for the AppStream repository to use thehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/AppStream/address.Change the
urlcommand to usehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/as the installation source.Comment out the
networkcommand.Change the
rootpwcommand to setredhatas the root user password.Modify the
authselectcommand to set thesssdservice as the identity and authentication source.Modify the
servicescommand to disable thekdumpandrhsmcertdservices and enable thesshd,rngd, andchronydservices.Delete the
partcommands and add theautopartcommand.
Simplify the
%postsection so that it only runs a script to append the textKickstarted on DATEat the end of the/etc/issuefile. Use thedatecommand to insert the date with no additional options.Simplify the
%packagesection as follows: include the@core,chrony,dracut-config-generic,dracut-norescue,firewalld,grub2,kernel,rsync,tar, andhttpdpackages. Ensure that theplymouthpackage does not install.Validate the syntax of the
kickstart.cfgkickstart file.Make the
/home/student/kickstart.cfgfile available at thehttp://serverb.lab.example.com/ks-config/kickstart.cfgaddress.
Instructions
On
serverb, install the container tools package.The container image registry at
registry.lab.example.comstores therhel8/mariadb-103image with several tags. Use thepodsvcuser to list the available tags and note the tag with the lowest version number. Use theadminuser andredhat321password to authenticate to the registry. Use the/tmp/registries.conffile as a template for the registry configuration.As the
podsvcuser, create the/home/podsvc/db_datadirectory. Configure the directory so that containers have read/write access.Create the
inventorydbdetached container. Use therhel8/mariadb-103image from theregistry.lab.example.comregistry, and specify the tag with the lowest version number on that image, which you found in a preceding step.Map port 3306 in the container to port 13306 on the host.
Mount the
/home/podsvc/db_datadirectory on the host as/var/lib/mysql/datain the container.Declare the following variable values for the container:
VariableValueMYSQL_USER
operator1
MYSQL_PASSWORD
redhat
MYSQL_DATABASE
inventory
MYSQL_ROOT_PASSWORD
redhat
You can copy and paste these parameters from the
/home/podsvc/containers-review/variablesfile onserverb.Execute the
/home/podsvc/containers-review/testdb.shscript to confirm that the MariaDB database is running.
Configure the
systemddaemon so that theinventorydbcontainer starts automatically when the system boots.
Last updated
Was this helpful?