Book tasks:
Instructions:
Display the current time and date: Use the
date
command to display the current time and date.Display current time in 24-hour clock format: Use the format string
%R
with thedate
command 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/zcat
is and whether it is human-readable.Check the size of
zcat
: Use thewc
command and Bash shortcuts to display the size of thezcat
file.Display the first 10 lines of the
zcat
file: Use the appropriate command to show the first 10 lines of the file.Display the last 10 lines of the
zcat
file: Use the command to display the last 10 lines of thezcat
file.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
zcat
file: Use thetail
command with the-n 20
option to display the last 20 lines of the file.Run the
date
command again using shell history: Use the shell history to run thedate +%R
command again.
Instructions
Use the
ssh
command to log in to theserverb
machine as thestudent
user. The system's configuration supports the use of SSH keys for authentication.Create a directory called
project_plans
in theDocuments
directory. TheDocuments
directory should be placed in thestudent
user's home directory. Create two empty files in theproject_plans
directory calledseason1_project_plan.odf
andseason2_project_plan.odf
. Hint: If the~/Documents
directory does not exist, then use themkdir -p
option 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.ogg
in the/home/student
directory. ReplaceX
with the season number andY
with 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
. ReplaceX
with the numbers 1 through 8.Use a single command to create two subdirectories called
season1
andseason2
under theVideos
directory 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_bestseller
subdirectory under theDocuments
directory, and thechapters
subdirectory under the newmy_bestseller
directory. Create three more subdirectories directly under themy_bestseller
directory with a single command. Name these subdirectorieseditor
,changes
, andvacation
. You do not need to use themkdir -p
command to create parents because themy_bestseller
parent directory exists.Change to the
chapters
directory. Use the tilde (~
) home directory shortcut to move all book chapters to thechapters
directory, 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
editor
directory to avoid modifying them during the review. Starting from thechapters
subdirectory, 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
chapters
directory to thevacation
directory. 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 thevacation
directory. Use a singlecd
command to change from your working directory to the~/Documents/my_bestseller/vacation
directory. List its files. Use the previous working directory argument to return to theseason2
directory. (This argument succeeds if the last directory change with thecd
command used one command rather than severalcd
commands.) From theseason2
directory, copy the episode 2 file into thevacation
directory. Use the shortcut again to return to thevacation
directory.The authors of chapters 5 and 6 want to experiment with possible changes. Copy both files from the
~/Documents/my_bestseller/chapters
directory to the~/Documents/my_bestseller/changes
directory to prevent these changes from modifying original files.Navigate to the
~/Documents/my_bestseller
directory. Use square-bracket pattern matching to specify which chapter numbers to match in the filename argument of thecp
command.Change your current directory to the
changes
directory and use thedate +%F
command with command substitution to copymystery_chapter5.odf
to a new file that includes the full date. Use themystery_chapter5_YYYY-MM-DD.odf
name format.By using command substitution with the
date +%s
command, 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
changes
directory.If it is necessary, then navigate to the
changes
directory 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
changes
directory. Try to delete the empty directory by using therm
command without the-r
recursive option. This attempt should fail. Finally, use thermdir
command to delete the empty directory, which succeeds.When the vacation is over, you no longer need the
vacation
directory. Delete it by using therm
command 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.odf
file 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/backups
directory does not exist, then use themkdir
command 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.ps
and place it in the student user's home directory. Determine the file content format. Inspect the contents of thepasswd.ps
file by using theless
command. 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:This 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 usingevince
three 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-tools
package subdirectory. View thekexec-kdump-howto.txt
file, which describes important system configuration options that are stored in the/etc/sysconfig
directory.
Instructions
On workstation, create the
lab_file
shell variable and assignediting_final_lab.txt
as the value.List the student home directory, including hidden directories and files, and redirect the output to the
editing_final_lab.txt
file by using the shell variable.Use Vim to edit the
editing_final_lab.txt
file. Use thelab_file
shell 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.txt
file.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
Desktop
andPublic
strings.Save your changes and exit the file.
Back up the
editing_final_lab.txt
file and append the date (in seconds) at the end of the file name preceded with an underscore (_
) character. Use thelab_file
shell variable.Append a dashed line to the
editing_final_lab.txt
file. The dashed line should contain 12 dash (-
) characters for this lab to be graded correctly. Use thelab_file
shell variable.List the content of the
Document
directory and redirect the output to theediting_final_lab.txt
file. Use thelab_file
shell variable.Confirm that the directory listing is at the bottom of the lab file. Use the
lab_file
shell variable.
Instructions
From the workstation machine, open an SSH session to the
serverb
machine as thestudent
user and switch to the root user.On the
serverb
machine, ensure that newly created users must change their passwords every 30 days.Create the
consultants
group with a GID of 35000.Configure administrative rights to enable all
consultants
group members to execute any command as any user.Create the
consultant1
,consultant2
, andconsultant3
users with theconsultants
group as their secondary group.Set the
consultant1
,consultant2
, andconsultant3
passwords toredhat
.Set the
consultant1
,consultant2
, andconsultant3
accounts to expire in 90 days from the current day.Change the password policy for the
consultant2
account to require a new password every 15 days.Additionally, force the
consultant1
,consultant2
, andconsultant3
users to change their passwords on the first login.
Instructions
Log in to
serverb
as thestudent
user. Switch to the root user, and useredhat
as the password.Create a
/home/techdocs
directory.Change the group ownership of the
/home/techdocs
directory to thetechdocs
group.Verify that users in the
techdocs
group cannot create files in the/home/techdocs
directory.Set permissions on the
/home/techdocs
directory. On the/home/techdocs
directory, 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
techdocs
group now has write permission.Confirm that users in the
techdocs
group can now create and edit files in the/home/techdocs
directory. Users that are not in thetechdocs
group cannot edit or create files in the/home/techdocs
directory. Thetech1
andtech2
users are in thetechdocs
group. Thedatabase1
user is not in that group.Modify the global login scripts. Normal users should have a
umask
setting 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
serverb
as thestudent
user. Create theprocess101
script in the/home/student/bin
directory. Theprocess101
script generates artificial CPU load:In the right terminal shell, run the
top
utility.In the left terminal shell, verify the number of logical CPUs on the virtual machine. Run the
process101
script in the background.In the right terminal shell, observe the
top
display. Note the process ID (PID) and view the CPU percentage that theprocess101
process uses. The CPU percentage that the process uses should hover around 10% to 15%. Toggle thetop
utility display between load, threads, and memory. Return to the CPU usage display of thetop
utility.Turn off the use of bold in the display. Save this configuration for reuse when
top
is restarted. Confirm that the changes are saved.Copy the
process101
script to a newprocess102
file, and increase the artificial CPU load to one hundred thousand in the new script. Start theprocess102
process in the background.In the right terminal shell, verify that the
process102
is 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
process101
script to a new script calledprocess103
. Increase the addition count to eight hundred thousand. Startprocess103
in 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
process101
process. List the remaining jobs. Observe that the process state forprocess101
is now in the T state.Resume the
process101
process.Terminate
process101
,process102
, andprocess103
from the command line. Verify that the processes are no longer displayed intop
.Stop processes and return to the workstation machine.
Instructions
Use the
ssh
command to log in to theserverb
machine as thestudent
user. On theserverb
machine, start thepsacct
service.Configure the
psacct
service to start at system boot.Stop the
rsyslog
service.Configure the
rsyslog
service so that it does not start at system boot.Reboot the
serverb
machine before evaluating the lab.
Instructions
From the workstation machine, log in to the
servera
machine as thestudent
user.Switch to the
production1
user on theservera
machine. Enterredhat
as the password.Generate passphrase-less SSH keys for the
production1
user on theservera
machine.Send the public key of the SSH key pair to the
production1
user on theserverb
machine.Verify that the
production1
user can successfully log in to theserverb
machine with the SSH keys.Configure the
sshd
service onserverb
to prevent users from logging in as the root user. Useredhat
as the root password.Configure the
sshd
service on theserverb
machine to allow users to authenticate with SSH keys only, rather than with their passwords.
Instructions
Log in to the
serverb
machine as thestudent
user.Pretend that the
serverb
machine 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
serverb
machine.Create the
/etc/rsyslog.d/auth-errors.conf
file. Configure thersyslog
service to write authentication and security messages to the/var/log/auth-errors
file. Use theauthpriv
facility and thealert
priority.
Instructions
Log in to the
serverb
machine as thestudent
user. 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.1
IP address with the private name.Reboot the system.
Verify that the
serverb
machine is initialized.
Instructions
On
serverb
, synchronize the/etc
directory tree fromservera
to the/configsync
directory.Create a
configfile-backup-servera.tar.gz
archive with the/configsync
directory contents.Securely copy the
/root/configfile-backup-servera.tar.gz
archive file fromserverb
to the/home/student
directory onworkstation
.On
workstation
, extract the contents to the/tmp/savedconfig/
directory.
Instructions
On the
serverb
machine, configure a software repository to obtain updates. Name the repositoryerrata
and configure the repository in the/etc/yum.repos.d/errata.repo
file. Configure theerrata.repo
file to use thehttp://content.example.com/rhel9.0/x86_64/rhcsa-practice/errata
repository. Do not check GPG signatures.On
serverb
, install therht-system
package.For security reasons, the
serverb
machine must not be able to connect to a paper printer. You can achieve this effect by removing thecups
package. When finished, exit from the root shell.The start script downloads the
rhcsa-script-1.0.0-1.noarch.rpm
package in the/home/student
directory on theserverb
machine.Confirm that the
rhcsa-script-1.0.0-1.noarch.rpm
package is available onserverb
and install it using root privileges. Verify that the package is installed.Exit from the
serverb
machine.
Instructions
On the
serverb
machine as the root user, identify the UUID for the/dev/vdb1
device, and mount it by using its UUID on the/mnt/freespace
directory.Generate a disk usage report for the
/usr/share
directory. Save the result in the/mnt/freespace/results.txt
file.Find all
rsyslog.conf
configuration files and store the result in the/mnt/freespace/search1.txt
file.Store the search result of all files in the
/usr/share
directory that are greater than 50 MB and less than 100 MB in the/mnt/freespace/search2.txt
file.Return to the
workstation
system as thestudent
user.
Instructions
Create the
/home/student/bin/bash-lab
script file on theworkstation
machine. 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
servera
andserverb
hosts. The systems use SSH keys for authentication, and therefore you do not require a password.Command or file
Content requested
hostname -f
Get all the output.
echo "#####"
Get all the output.
lscpu
Get only the lines that start with the string
CPU
.echo "#####"
Get all the output.
/etc/selinux/config
Ignore empty lines. Ignore lines starting with
#
.echo "#####"
Get all the output.
/var/log/secure
Get all "Failed password" entries.
echo "#####"
Get all the output.
Save the required information to the
output-servera
andoutput-serverb
files in the/home/student
directory onworkstation
.Note: You can use the
sudo
command without requiring a password on theservera
andserverb
hosts. Remember to use a loop to simplify your script. You can also use multiplegrep
commands that are concatenated with the use of the pipe character (|
).Execute the
/home/student/bin/bash-lab
script, and review the output content onworkstation
.
Instructions
Change the current tuning profile for the
serverb
machine 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
serverb
are 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
serverb
machine as thestudent
user and switch to the root user.From a web browser on the
workstation
machine, view thehttp://serverb/lab.html
web 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
workstation
machine as thestudent
user.
Instructions
The
serverb
machine 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
/backup
directory.On the same disk, create two 512 MB GPT partitions called
swap1
andswap2
. 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
swap2
partition to be preferred over the other.To verify your work, reboot the
serverb
machine. Confirm that the system automatically mounts the first partition onto the/backup
directory. 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/vdb
disk. Initialize this partition as a physical volume, and extend theserverb_01_vg
volume group to use this partition.Extend the
serverb_01_lv
logical volume to 768 MiB.In the existing volume group, create the new
serverb_02_lv
logical volume with 128 MiB. Add an XFS file system and mount it persistently on the/storage/data2
directory.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
serverb
machine is sharing the/shares
directory, which in turn contains themanagement
,production
, andoperation
subdirectories.The
managers
group consists of themanager1
andmanager2
users. They have read and write access to the/shares/management
exported directory.The
production
group consists of thedbuser1
andsysadmin1
users. They have read and write access to the/shares/production
exported directory.The
operators
group consists of thecontractor1
andconsultant1
users. They have read and write access to the/shares/operation
exported directory.The main mount point for
servera
is the/remote
directory.Use the
/etc/auto.master.d/shares.autofs
file as the master map file and the/etc/auto.shares
file as the indirect map file.The
/shares/management
exported directory is automounted on/remote/management
onservera
.The
/shares/production
exported directory is automounted on/remote/production
onservera
.The
/shares/operation
exported directory is automounted on/remote/operation
onservera
.All user passwords are set to
redhat
.
Log in to
servera
and install the required packages.Configure an automounter indirect map on
servera
with exports fromserverb
. Create an indirect map with files that are named/etc/auto.master.d/shares.autofs
for the master map and/etc/auto.shares
for the mapping file. Use the/remote
directory as the main mount point onservera
. Rebootservera
to determine whether the autofs service starts automatically.Test the autofs configuration with the various users. When done, log out from
servera
.
Instructions
On the
serverb
machine, reset the password toredhat
for the root user.Locate the icon for the
serverb
machine 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
serverb
machine.Change the default systemd target on the
serverb
machine for the system to automatically start a graphical interface when it boots.No graphical interface is installed on the
serverb
machine. 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
workstation
machine, test access to the default web server athttp://serverb.lab.example.com
and to the virtual host athttp://serverb.lab.example.com:1001
.Log in to the
serverb
machine to determine what is preventing access to the web servers.Configure SELinux to allow the
httpd
service to listen on port 1001/TCP.From
workstation
, test again access to the default web server athttp://serverb.lab.example.com
and to the virtual host athttp://serverb.lab.example.com:1001
.Log in to the
serverb
machine 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.com
and the virtual host atserverb.lab.example.com:1001
returnsSERVER 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
serverb
machine, copy the/root/anaconda-ks.cfg
kickstart file to the/home/student/kickstart.cfg
kickstart file for making it editable for thestudent
user.Make changes to the
/home/student/kickstart.cfg
kickstart file:Comment out the
reboot
command.Modify the
repo
command for the BaseOS and AppStream repositories. Modify therepo
command for the BaseOS repository to use thehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/BaseOS/
address. Modify therepo
command for the AppStream repository to use thehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/AppStream/
address.Change the
url
command to usehttp://classroom.example.com/content/rhel9.0/x86_64/dvd/
as the installation source.Comment out the
network
command.Change the
rootpw
command to setredhat
as the root user password.Modify the
authselect
command to set thesssd
service as the identity and authentication source.Modify the
services
command to disable thekdump
andrhsmcertd
services and enable thesshd
,rngd
, andchronyd
services.Delete the
part
commands and add theautopart
command.
Simplify the
%post
section so that it only runs a script to append the textKickstarted on DATE
at the end of the/etc/issue
file. Use thedate
command to insert the date with no additional options.Simplify the
%package
section as follows: include the@core
,chrony
,dracut-config-generic
,dracut-norescue
,firewalld
,grub2
,kernel
,rsync
,tar
, andhttpd
packages. Ensure that theplymouth
package does not install.Validate the syntax of the
kickstart.cfg
kickstart file.Make the
/home/student/kickstart.cfg
file available at thehttp://serverb.lab.example.com/ks-config/kickstart.cfg
address.
Instructions
On
serverb
, install the container tools package.The container image registry at
registry.lab.example.com
stores therhel8/mariadb-103
image with several tags. Use thepodsvc
user to list the available tags and note the tag with the lowest version number. Use theadmin
user andredhat321
password to authenticate to the registry. Use the/tmp/registries.conf
file as a template for the registry configuration.As the
podsvc
user, create the/home/podsvc/db_data
directory. Configure the directory so that containers have read/write access.Create the
inventorydb
detached container. Use therhel8/mariadb-103
image from theregistry.lab.example.com
registry, 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_data
directory on the host as/var/lib/mysql/data
in 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/variables
file onserverb
.Execute the
/home/podsvc/containers-review/testdb.sh
script to confirm that the MariaDB database is running.
Configure the
systemd
daemon so that theinventorydb
container starts automatically when the system boots.
Last updated
Was this helpful?