Practice Exam Topics Flashcards
Suppose on the exam, you are working with at least two separate RHEL VMs and you wish to switch between them quickly. Describe an easier method to do this instead of manually clicking between the two VM windows.
Open two terminal windows on the VM host and connect to the two guests via SSH. This way, you can just switch between the two terminal windows on the VM host.
Modify the ‘/etc/hosts’ files on the VM host so that you can connect via domain names rather than IP addresses.
On the exam, you may need to configure custom partitions during the installation procedure. How could you add a 1 GB swap partition during installation?
- Click on the ‘Installation Destination’ section
- Choose ‘Custom Storage Configuration’
- Click ‘Done’
- Click the ‘+’ symbol to add a new partition
- Specify the mount point and size
- After specifying all custom partitions, click ‘Done’
How could you reset the root password on a machine?
- Enter the Grub 2 menu and edit the boot parameters for your specific kernel
- Add ‘init=/bin/bash’ to the end of the Linux line and then boot
- Remount the root filesystem with read/write privileges via ‘mount -o remount,rw /’
- Change the root password via ‘passwd root’
- Create the ‘/.autorelabel’ file so that SELinux relabels the filesystem
- Run ‘exec /usr/lib/systemd/systemd’ to replace ‘/bin/bash’ with ‘Systemd’ as the first process
If you can’t remember how to restart the system with Systemd, you can just use the VM controls to restart the VM.
If ‘/.autorelabel’ causes the continuous loop bug, you can enter the system in Rescue mode (via the installation disk) and simply remove the ‘/.autorelabel’ file.
Suppose you have the RHEL 9 installation disk connected to the machine and you want to copy the ‘.iso’ file on the disc to ‘/rhel9.iso’
How could you do this?
dd if=/dev/sr0 of=/rhel9.iso -bs 1M
The ‘-bs’ option is used to specify the block size for the process. Specifying a block size of 1 megabyte will make this process much more efficient.
For this to work, you must ensure that the installation disk is connected in the virtual machine manager.
Suppose you have the ‘.iso’ file for RHEL 9 stored in the ‘/rhel9.iso’ directory and you wish to have this automatically mounted on the ‘/repo’ directory.
How could this be done?
Enter the following line into ‘/etc/fstab’
/rhel9.iso /repo iso9660 defaults 0 0
Suppose you need to configure your own repositories to be used. Which directory stores ‘.repo’ configuration files for repositories?
/etc/yum.repos.d
Files included in here must end with the ‘.repo’ extension.
Suppose you have the contents of the RHEL 9 .iso file mounted on the ‘/repo’ directory. How can you configure the BaseOS repository?
Create any file with the ‘.repo’ extension in the ‘/etc/yum.repos.d’ directory. Add the following to the file:
[BaseOS]
name=BaseOS
baseurl=file:///repo/BaseOS
gpgcheck=0
The main label within the square brackets and the name field can contain any value. The most important value is ‘baseurl’
Suppose you set up a RHEL VM but you didn’t give it enough storage space. How could you resize the disk for this KVM virtual machine to be 10 gigabytes larger?
Assume the VM’s disk is stored at ‘/var/lib/libvirt/images/rhel9-exam1.1.qcow2’ on the host.
On the host machine, execute ‘qemu-img resize /var/lib/libvirt/images/rhel9-exam1.1.qcow2 +10G’
For this to work, first turn of the relevant VM.
Suppose you already have a 1 gigabyte primary MBR partition named ‘/dev/vda3’ and you wish to format it with a vfat filesystem. How can you do this?
Also, assume you do not have the command that is used to format a partition with a vfat filesystem and you don’t know by which RPM it is provided.
- Execute ‘dnf wp */mkfs.vfat’
- After finding the correct RPM, execute ‘dnf install dosfstools’
- Execute ‘mkfs.vfat /dev/vda3’
How could you create a 1 gigabyte swap partition that is mounted persistently? Assume you’re using the ‘/dev/vdb’ device.
- Create the ‘/dev/vdb1’ partition via ‘fdisk /dev/vdb’
- Ensure that the ‘/dev/vdb1’ partition is of type ‘swap’ before writing the changes and exiting ‘fdisk’
- Execute ‘mkswap /dev/vdb1’
- Add the line ‘/dev/vdb1 none swap defaults 0 0’ to ‘/etc/fstab’
- Execute ‘swapon -a’ to activate all swap partitions
‘free -m’ can be used to verify how much swap space is being used.
How could you create a logical volume named ‘myfiles’ that consists of 75 extents?
The volume group to which it belongs should be named ‘vglab’ and use 8 MiB extents. The logical volume should be formatted with an ext4 filesystem and should be mounted persistently on the ‘/myfiles’ directory.
Assume you are using the ‘/dev/vdb’ device. Give the partition 10 gigabytes of space.
- Execute ‘fdisk /dev/vdb’ and create a new ‘/dev/vdb1’ partition of 10 gigabytes and of type ‘lvm’
- Execute ‘vgcreate -s 8M vglab /dev/vdb1’
- Execute ‘lvcreate -n myfiles -l 75 /dev/vglab’
- Execute ‘mkfs.ext4 /dev/vglab/myfiles’
- Add the line ‘/dev/vglab/myfiles /myfiles ext4 defaults 0 0’ to ‘/etc/fstab’
Suppose you already have a logical volume named ‘/dev/vglab/myfiles’ and you wish to expand it by 5 gigabytes. How could this be done?
lvextend -r -L +5G /dev/vglab/myfiles
Make sure to include the ‘-r’ option to also extend the filesystem along with the volume.
How would you create a user named ‘lisa’ that is a member of the secondary group ‘sales’ and that has a UID of 1234?
useradd -u 1234 -G sales lisa
How would you create a user named ‘myapp’ that does not have a login shell?
useradd -s /sbin/nologin myapp
Suppose there is a ‘/sales’ directory. Ensure that ‘lisa’ is the owner of ‘/sales’ and the ‘sales’ group is the group owner. Then, ensure that the owner and the group owner both have full access (read, write, execute) to the directory while all others have no access. Also ensure that every file that is created in ‘/sales’ is automatically group owned by the ‘sales’ group. What commands will accomplish this?
- Execute ‘chown lisa:sales /sales’
- Execute ‘chmod 2770 /sales’
The 2 will give the directory the SGID permission.
How would you schedule a job that writes ‘hello folks’ to syslog every Monday through Friday at 2 AM?
Ensure that this job is executed as user ‘lisa’
- Log in as user ‘lisa’
- Execute ‘crontab -e’ to edit the crontab for the current user
- Add the line ‘0 2 * * 1-5 logger hello folks’ and then save the changes
Create a container with the name ‘mydb’ that runs the ‘mariadb’ database as user ‘lisa’
The container should automatically be started at system start, regardless of whether or not ‘lisa’ is logged in.
The host directory ‘/home/lisa/mydb’ should be mounted on the container directory ‘/var/lib/mysql’
The container should also be accessible on host TCP port 3206.
- First, as root, enable linger for user ‘lisa’ by executing ‘loginctl enable-linger lisa’
- Log in as user ‘lisa’ via an SSH session.
- Create the ‘/home/lisa/mydb’ directory.
- Execute ‘podman run -d –name mydb -e MYSQL_ROOT_PASSWORD=password -v /home/lisa/mydb:/var/lib/mysql:Z -p 3206:3306 mariadb
- Find the relevant user in the container’s ‘/etc/passwd’ file and ensure that the correct user is owner of ‘/home/lisa/mydb’
- Open the host firewall by executing ‘firewall-cmd –add-port=3206/tcp –permanent’ and then executing ‘firewall-cmd –reload’
- Next, create the ‘/home/lisa/.config/systemd/user’ directory and move into it
- Execute ‘podman generate systemd –name mydb –files –new’ to create the Systemd ‘.service’ file for the container
- Execute ‘systemctl –user daemon-reload’ and then ‘systemctl –user enable container-mydb.service’
How could you share the directories ‘/homes/user1’ and ‘/homes/user2’ via NFS? Ensure that the firewall does not block access to these directories.
- Install the ‘nfs-utils’ package
- Add the line ‘/homes *(rw,no_root_squash)’ to the ‘/etc/exports’ file.
- Execute ‘systemctl enable –now nfs-server’ to enable the NFS service.
- Add the ‘nfs-server’ ‘rpc-bind’ and ‘mountd’ services to the firewall configuration via ‘firewall-cmd –add-service’ and then reload the permanent firewall configuration to the runtime environment.
How could you configure the ‘server2:/homes/user1’ and ‘server2:/homes/user2’ NFS-shared directories to be automatically mounted on the ‘/homes/user1’ and ‘/homes/user2’ directories respectively when these directories are accessed?
- Ensure that the ‘nfs-utils’ and ‘autofs’ RPMs are installed.
- Go to the ‘/etc/auto.master’ file and add the line ‘/homes /etc/auto.homes’
- In ‘/etc/auto.homes’ add the line ‘* -rw server2:/homes/&’
- Execute ‘systemctl enable –now autofs’
Configure your server to be an NTP client for ‘pool.ntp.org’
- Edit the ‘/etc/chrony.conf’ file.
- Comment out the original NTP pool line.
- Add the line ‘pool pool.ntp.org iburst’
- Restart the chronyd daemon via ‘systemctl restart chronyd’
- Check that NTP is working via the ‘chronyc sources’ command.
How could you install the Apache web server and then serve content from the ‘/web’ DocumentRoot?
- Install Apache via ‘dnf install httpd’
- Edit ‘/etc/httpd/conf/httpd.conf’ and change the ‘DocumentRoot’ line to point to ‘/web’ rather than the default.
- Also change the tag that relaxes access to the DocumentRoot directory to point to ‘/web’ rather than the default. Save the changes and exit.
- Update the SELinux file context type for the new DocumentRoot by executing ‘semanage fcontext -a -t httpd_sys_content_t “/web(/.*)?”’ and then executing ‘restorecon -R -v /web’
- Finally, enable or restart Apache (httpd)
You can test the web server via ‘curl localhost’
How could you search for a zombie process in the output of the ‘ps’ command?
ps aux | grep defunct
A zombie command will have the ‘defunct’ identifier on its line in the ‘ps aux’ output. Additionally, it will have a value of ‘Z’ in the state column.
Suppose you have a ‘dd’ process that is running with PID of 8664. Other than via ‘top’ how could you request that this process stop?
kill 8664
By default, ‘kill’ sends the ‘SIGKTERM’ (code 15) signal to the specified process.
How could you permanently (across reboots) set the ‘swappiness’ to 40 on your RHEL 9 machine?
- Open the ‘/etc/sysctl.d/swappiness.conf’ file in an editor
- Add the line ‘vm.swappiness=40’ and save the changes
- Activate the change with ‘sysctl -p /etc/sysctl.d/swappiness.conf’
The ‘-p’ option tells ‘sysctl’ to load in the settings from the specified file or, if no file is specified, from ‘/etc/sysctl.conf’