Practice Exam Topics Flashcards

1
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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?

A
  1. Click on the ‘Installation Destination’ section
  2. Choose ‘Custom Storage Configuration’
  3. Click ‘Done’
  4. Click the ‘+’ symbol to add a new partition
  5. Specify the mount point and size
  6. After specifying all custom partitions, click ‘Done’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How could you reset the root password on a machine?

A
  1. Enter the Grub 2 menu and edit the boot parameters for your specific kernel
  2. Add ‘init=/bin/bash’ to the end of the Linux line and then boot
  3. Remount the root filesystem with read/write privileges via ‘mount -o remount,rw /’
  4. Change the root password via ‘passwd root’
  5. Create the ‘/.autorelabel’ file so that SELinux relabels the filesystem
  6. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

A

Enter the following line into ‘/etc/fstab’

/rhel9.iso /repo iso9660 defaults 0 0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Suppose you need to configure your own repositories to be used. Which directory stores ‘.repo’ configuration files for repositories?

A

/etc/yum.repos.d

Files included in here must end with the ‘.repo’ extension.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Suppose you have the contents of the RHEL 9 .iso file mounted on the ‘/repo’ directory. How can you configure the BaseOS repository?

A

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’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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.

A
  1. Execute ‘dnf wp */mkfs.vfat’
  2. After finding the correct RPM, execute ‘dnf install dosfstools’
  3. Execute ‘mkfs.vfat /dev/vda3’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How could you create a 1 gigabyte swap partition that is mounted persistently? Assume you’re using the ‘/dev/vdb’ device.

A
  1. Create the ‘/dev/vdb1’ partition via ‘fdisk /dev/vdb’
  2. Ensure that the ‘/dev/vdb1’ partition is of type ‘swap’ before writing the changes and exiting ‘fdisk’
  3. Execute ‘mkswap /dev/vdb1’
  4. Add the line ‘/dev/vdb1 none swap defaults 0 0’ to ‘/etc/fstab’
  5. Execute ‘swapon -a’ to activate all swap partitions

‘free -m’ can be used to verify how much swap space is being used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A
  1. Execute ‘fdisk /dev/vdb’ and create a new ‘/dev/vdb1’ partition of 10 gigabytes and of type ‘lvm’
  2. Execute ‘vgcreate -s 8M vglab /dev/vdb1’
  3. Execute ‘lvcreate -n myfiles -l 75 /dev/vglab’
  4. Execute ‘mkfs.ext4 /dev/vglab/myfiles’
  5. Add the line ‘/dev/vglab/myfiles /myfiles ext4 defaults 0 0’ to ‘/etc/fstab’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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?

A

lvextend -r -L +5G /dev/vglab/myfiles

Make sure to include the ‘-r’ option to also extend the filesystem along with the volume.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How would you create a user named ‘lisa’ that is a member of the secondary group ‘sales’ and that has a UID of 1234?

A

useradd -u 1234 -G sales lisa

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How would you create a user named ‘myapp’ that does not have a login shell?

A

useradd -s /sbin/nologin myapp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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?

A
  1. Execute ‘chown lisa:sales /sales’
  2. Execute ‘chmod 2770 /sales’

The 2 will give the directory the SGID permission.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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’

A
  1. Log in as user ‘lisa’
  2. Execute ‘crontab -e’ to edit the crontab for the current user
  3. Add the line ‘0 2 * * 1-5 logger hello folks’ and then save the changes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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.

A
  1. First, as root, enable linger for user ‘lisa’ by executing ‘loginctl enable-linger lisa’
  2. Log in as user ‘lisa’ via an SSH session.
  3. Create the ‘/home/lisa/mydb’ directory.
  4. Execute ‘podman run -d –name mydb -e MYSQL_ROOT_PASSWORD=password -v /home/lisa/mydb:/var/lib/mysql:Z -p 3206:3306 mariadb
  5. Find the relevant user in the container’s ‘/etc/passwd’ file and ensure that the correct user is owner of ‘/home/lisa/mydb’
  6. Open the host firewall by executing ‘firewall-cmd –add-port=3206/tcp –permanent’ and then executing ‘firewall-cmd –reload’
  7. Next, create the ‘/home/lisa/.config/systemd/user’ directory and move into it
  8. Execute ‘podman generate systemd –name mydb –files –new’ to create the Systemd ‘.service’ file for the container
  9. Execute ‘systemctl –user daemon-reload’ and then ‘systemctl –user enable container-mydb.service’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How could you share the directories ‘/homes/user1’ and ‘/homes/user2’ via NFS? Ensure that the firewall does not block access to these directories.

A
  1. Install the ‘nfs-utils’ package
  2. Add the line ‘/homes *(rw,no_root_squash)’ to the ‘/etc/exports’ file.
  3. Execute ‘systemctl enable –now nfs-server’ to enable the NFS service.
  4. 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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?

A
  1. Ensure that the ‘nfs-utils’ and ‘autofs’ RPMs are installed.
  2. Go to the ‘/etc/auto.master’ file and add the line ‘/homes /etc/auto.homes’
  3. In ‘/etc/auto.homes’ add the line ‘* -rw server2:/homes/&’
  4. Execute ‘systemctl enable –now autofs’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Configure your server to be an NTP client for ‘pool.ntp.org’

A
  1. Edit the ‘/etc/chrony.conf’ file.
  2. Comment out the original NTP pool line.
  3. Add the line ‘pool pool.ntp.org iburst’
  4. Restart the chronyd daemon via ‘systemctl restart chronyd’
  5. Check that NTP is working via the ‘chronyc sources’ command.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How could you install the Apache web server and then serve content from the ‘/web’ DocumentRoot?

A
  1. Install Apache via ‘dnf install httpd’
  2. Edit ‘/etc/httpd/conf/httpd.conf’ and change the ‘DocumentRoot’ line to point to ‘/web’ rather than the default.
  3. Also change the tag that relaxes access to the DocumentRoot directory to point to ‘/web’ rather than the default. Save the changes and exit.
  4. 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’
  5. Finally, enable or restart Apache (httpd)

You can test the web server via ‘curl localhost’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How could you search for a zombie process in the output of the ‘ps’ command?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

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?

A

kill 8664

By default, ‘kill’ sends the ‘SIGKTERM’ (code 15) signal to the specified process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How could you permanently (across reboots) set the ‘swappiness’ to 40 on your RHEL 9 machine?

A
  1. Open the ‘/etc/sysctl.d/swappiness.conf’ file in an editor
  2. Add the line ‘vm.swappiness=40’ and save the changes
  3. 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’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

How could you force every new user password to have a length of at least 6 characters?

A
  1. Open the ‘/etc/security/pwquality.conf’ file
  2. Add the line ‘minlen = 6’ and save the changes
26
Q

Which two files are used to configure default values for new user accounts?

A

‘/etc/default/useradd’ is used to configure things such as the home directory, default shell, skeleton directory, etc.

‘/etc/login.defs’ is used to configure things such as default password expiration properties, the path variable, whether or not to create a home directory, etc.

27
Q

What does the sticky bit permission do when set for a directory?

A

When the sticky bit is set only the user who owns a file within the directory can delete their own file.

However, the two exceptions are the user that owns the directory, or the root. They can both also delete any files within the directory.

28
Q

Which line can be added to the ‘/etc/ssh/sshd_config’ file to allow the root user to log-in via an SSH session?

A

PermitRootLogin yes

Make sure to restart the ‘sshd’ daemon after making this change.

29
Q

Suppose you’ve created a new group named ‘sysadmins’ and you’ve added some users to the group. How could you allow members of this group to run all ‘sudo’ commands?

A
  1. Open the ‘/etc/sudoers’ file via the ‘visudo’ command.
  2. Add the line ‘%sysadmins ALL=(ALL) ALL’ and save the changes.

Now, every member of the ‘sysadmins’ group can run any command.

30
Q

What do the fields mean in this line from the ‘/etc/sudoers’ file?

root ALL = (ALL:ALL) ALL

A

The first ‘ALL’ defines which hosts to which this line applies. The second and third ‘ALL’ fields describe as which user:group that ‘root’ is allowed to run commands. Finally, the last ‘ALL’ field describes what commands the root user can run.

31
Q

How could you allow the user ‘linda’ to add new users and change their passwords but still restrict them from changing the root password?

A

Add the following line to ‘/etc/sudoers’

linda ALL=/usr/bin/useradd, /usr/bin/passwd, ! /usr/bin/passwd root

32
Q

How could you schedule a job to run via the ‘cron.{hourly,daily,monthly,weekly}’ directories?

A

Simply create a file in the desired directory (it doesn’t need to have an extension) and then add your commands/script to it. Make sure it is executable!

Set the executable bit via ‘chmod +x’

33
Q

How do cron jobs scheduled via the ‘/etc/cron.d’ directory differ from other cron jobs?

A

The jobs in ‘cron.d/’ (and also ‘/etc/crontab’) both require a username in addition to the time and command(s) to run.

34
Q

How could you manually write the current history to the ‘~/.bash_history’ file?

A

history -w

35
Q

Suppose you’ve typed out a lot of text into the Bash shell and you wish to clear the line. How could you do this?

A

Ctrl-u

36
Q

How could you easily move backwards/forwards across words typed out on the Bash command line?

A

Alt-b (backward)
Alt-f (forward)

37
Q

How could you list all files within all directories that start with a, b, c, d, or e in the current directory?

A

ls [a-e]*

38
Q

How could you add the users linda, lisa, and matthew all in one command?

A

useradd {linda,lisa,matthew}

39
Q

In the Bash shell, what is the difference between double and single quotes in the context of shell expansion?

A

Double quotes suppress globbing and shell expansion but do allow command and variable substitution. ($ symbol will still be interpreted)

Single quotes take away the special meaning of any characters.

40
Q

How could you print the 5th line of the ‘/etc/passwd’ file with just the ‘sed’ command?

A

sed -n 5p /etc/passwd

The ‘-n’ option prevents each line of input being echoed to the standard output. Without the ‘-n’ option, the command would print each line of ‘/etc/passwd’ along with a second print of the matching line which in this case would be the fifth line.

41
Q

How could you use the ‘grep’ command to search for all occurrences of the string ‘alex’ but not ‘alexander’ in all files in the ‘/etc’ directory?

A

grep ‘\balex\b’ /etc/*

The ‘\b’ stands for a word boundary. In this instance it is being applied to both the beginning and end of the string.

42
Q

For each user, how could you increase the duration of the ‘sudo’ token to 60 minutes?

A

Add the following line to ‘/etc/sudoers’ (via ‘visudo’):

Defaults timestamp_type=global,timestamp_timeout=60

43
Q

If during the exam while installing a RHEL 9 virtual machine you are asked to configure the VM with two virtual drives, how could you do this?

‘/dev/vda’ and ‘/dev/vdb’

A

On the host machine, when creating a new virtual machine and right before you click ‘Finish’, make sure to select ‘Customize configuration before install’ to add a second storage device.

44
Q

Suppose you have the ‘/dev/vdb1’ partition and you wish to format it with an ext4 filesystem and give it the label ‘mydata’. How could you do this?

A

mkfs.ext4 -L mydata /dev/vdb1

45
Q

How could you find all files that have the SUID permission set, and write the result to the file ‘/root/suidfiles’ ?

A

find / -type f -perm -u=s -fprint /root/suidfiles

The ‘-type f’ option specifies to only look for files while ‘-perm -u=s’ will look for ones that have the SUID bit set. The ‘-fprint’ option will print the full filename into the file given.

Make sure to include the ‘-‘ before the permissions as using ‘-perm u=s’ will look for files that ONLY have the SUID bit set and nothing else.

46
Q

How could you add a 10-GiB disk to your virtual machine and on this disk, create a Stratis pool named ‘mypool’
and then a volume from that pool? Use the name ‘stratisvol’ for the volume, and mount it persistently on the ‘/stratis’ directory.

A
  1. Install the ‘stratisd’ and ‘stratis-cli’ packages.
  2. Add a new disk to the virtual machine by configuring the VM settings on the host machine.
  3. Assuming the new disk is ‘/dev/vdc’, execute ‘stratis pool create mypool /dev/vdc’
  4. Next, execute ‘stratis fs create mypool stratisvol’
  5. Then, get the UUID for the new Stratis filesystem by executing ‘stratis fs list’
  6. Next, add the line ‘UUID=123456789 /stratis xfs x-systemd.requires=stratisd.service 0 0’ to the ‘/etc/fstab’ file.
  7. Finally, ensure that ‘stratisd’ is enabled.
47
Q

Suppose you’ve attempted to execute some command but were denied due to lacking privileges. How could you run the last command attempted but with root privileges?

A

sudo !!

48
Q

Suppose you want to use the ‘AppStream’ repository that is available via ‘ftp://server2/pub/repofiles/repo/’

How can you configure this to be used via a command line tool? (not manually)

A

dnf config-manager –add-repo=ftp://server2/pub/repofiles/repo/AppStream

This method does not automatically add the ‘gpgcheck=0’ line to the ‘.repo’ file.

49
Q

How could you persistently change the hostname to ‘rhel-server.example.com’ ? There are two main methods.

A
  1. Directly edit the ‘/etc/hostname’ file
  2. Execute ‘hostnamectl hostname rhel-server.example.com’ which will automatically edit the contents of ‘/etc/hostname’
50
Q

How could you locate all files containing the text “root” in the /etc directory and write that to ‘/root/output.txt’ ?

A

find /etc -type f -exec grep -l “root” {} + > /root/output.txt

The ‘-l’ option will supress the normal output and instead print the name of each file.

51
Q

How would you configure time synchronization, such that your server (server1.example.com) is synchronizing time with server2.example.com?

Assume both machines are on the 192.168.122.0/24 subnet.

A
  1. On server2, open ‘/etc/chrony.conf’
  2. Disable the ‘pool 2.rhel.pool.ntp.org iburst’ line.
  3. Add the line ‘allow 192.168.122.0/24’ to allow access from all clients in the subnet.
  4. Include the line ‘local stratum 8’ to ensure that the local time server is going to advertise itself with a stratum of 8.
  5. Add the ‘ntp’ service to the permanent firewall and then reload the runtime configuration.
  6. Restart the ‘chronyd’ daemon and move to server1.
  7. On server1, open ‘/etc/chrony.conf’ and disable the ‘pool 2.rhel.pool.ntp.org iburst’ line.
  8. Add the line ‘server server2.example.com’ and ensure that name resolution is configured between the hosts.
  9. Restart the ‘chronyd’ daemon and check via ‘chronyc sources’
52
Q

How would you list all files within the current directory that start with an a, b, c, d, or e?

A

ls | grep “^[abcde]”

53
Q

How could you search for SELinux related logs?

A

grep AVC /var/log/audit/audit.log

SELinux logs can be found via the identifier ‘AVC’

54
Q

Suppose you are experiencing the ‘infinite /.autorelabel’ bug with SELinux. How can you fix this?

A
  1. Via the Grub2 bootloader, boot RHEL in emergency mode by adding the ‘systemd.unit=emergency.target’ boot parameter.
  2. Next, remount the root filesystem so that it is writable.
  3. Then, remove the ‘/.autorelabel’ file.
  4. Manually relabel the filesystem via ‘restorecon -R -v /’
  5. Reboot the machine.
55
Q

How could you find all files that are owned by user ‘edwin’ and then copy those files to the ‘/rootedwinfiles’ directory?

A

find / -type f -user edwin -exec cp -p ‘{}’ /rootedwinfiles \;

The ‘-p’ option will preserve all ownership of the files being copied. The ‘{}’ represents the file discovered by the ‘find’ command and should be enclosed in quotes to prevent expansion by the shell.

56
Q

How could you create a container named ‘web-server’ that runs an HTTP server that also mounts the host directory ‘/httproot’ on the container ‘/var/www/html’ directory?

A

Execute ‘podman run -d –name web-server -p 80:8080 -v /httproot:/var/www/html:Z registry.access.redhat.com/httpd-24’

This ‘httpd’ container listens on port 8080 so the host port 80 must be forwarded to the container port 8080. An ‘index.html’ file can be created in the ‘/httproot’ directory on the host. Make sure to open up port 80 on the host firewall.

57
Q

If you are asked to configure a container to automatically start on system boot as a system user service, what should you do?

A

Generate a Systemd user unit file for the service in the user-specific ‘~/.config/systemd/user’ directory.
Then make sure to enable linger for this user and enable the newly generated ‘.service’ file via ‘systemctl –user enable’ command.
Ensure that the new ‘.service’ file includes the line ‘WantedBy=default.target’

58
Q

Suppose you want every new user to automatically have an empty file named ‘NEWFILE’ created in their home directory upon account creation. How can you make this happen?

A

Ensure that the skeleton directory (often ‘/etc/skel’) includes the ‘NEWFILE’ file.

59
Q

How could you resize the LVM logical volume containing the root filesystem to be 1 Gibibyte larger?

A

lvextend -r -L +1G /dev/rhel/root

First add more space to the appropriate logical volume group. Create a new ‘lvm’ partition and add it to the group via the ‘vgextend’ command. The ‘-r’ option of ‘lvextend’ will resize the filesystem along with the logical volume.

60
Q

Suppose you have a kickstart file named ‘anaconda-ks.cfg’ and you wish to verify that it uses correct syntax. How could you do this?

A

ksvalidator anaconda-ks.cfg

61
Q

Suppose you want to build a container image from the ‘Containerfile’ located in the ‘~/rhcsa’ directory. The container image should be named ‘runmap’ and you are currently in your home directory. How can you do this?

A

podman build -t runmap rhcsa/

The ‘-t’ option allows one to specify the tag (name) for the resulting container image.