# Free RHCSA practice questions

> 10 free RHCSA practice questions with the correct answer and an explanation.

Page: https://devopscodelab.com/exams/redhat-ex200/free-practice-questions/
Practice exams: https://devopscodelab.com/exams/redhat-ex200/

### Question 1 of 10

An auditor needs every line in /etc/ssh/sshd_config that is neither empty nor a comment, so only active directives remain. Which command produces that list?

- A. grep -Ev '^(#|$)' /etc/ssh/sshd_config
- B. grep -E '^#|^$' /etc/ssh/sshd_config
- C. grep -v '#' /etc/ssh/sshd_config | grep -v ' '
- D. grep -c -v '^#' /etc/ssh/sshd_config

**Answer:** A

**Explanation:** The extended regular expression ^(#|$) matches lines that start with a hash or are completely empty, and -v inverts the match so only active directives are printed. Filtering any line containing # or a space also discards valid directives that contain spaces or trailing comments. Without -v the pattern prints exactly the comments and blank lines, and -c prints a count rather than the lines.

### Question 2 of 10

A dnf update performed an hour ago broke an application, and the administrator wants to revert exactly that transaction. Which approach is correct?

- A. Run rpm -Va to restore the files that the transaction modified to their earlier contents.
- B. Find the transaction ID with dnf history list, then run dnf history undo with that ID.
- C. Run dnf downgrade with no arguments to return every package to its previous release.
- D. Run dnf history rollback 0 to return the system to the state at installation time.

**Answer:** B

**Explanation:** dnf history list shows numbered transactions, and dnf history undo reverses a specific one by downgrading or removing the affected packages, as long as the older versions are still available. downgrade needs package names, rpm -Va only verifies files against the database, and rolling back to the first transaction would revert far more than the single faulty update.

### Question 3 of 10

A script is called as ./adduser.sh alice 'mary ann' bob and loops over its arguments. What is the effect of writing for name in "$@" compared with for name in "$*"?

- A. "$@" and "$*" behave identically when quoted, and both loop three times over the arguments
- B. "$@" loops over the arguments after the first; "$*" loops over every argument including $0
- C. "$@" loops four times because it splits 'mary ann'; "$*" loops three times, once per argument
- D. "$@" loops three times, once per argument; "$*" loops once over a single joined string

**Answer:** D

**Explanation:** Quoted $@ expands to each positional parameter as a separate word and keeps 'mary ann' intact, so the loop runs three times. Quoted $* joins all parameters into one word separated by the first character of IFS, so the loop runs once. Neither form includes $0, and quoted $@ never splits an argument at embedded spaces.

### Question 4 of 10

After a reboot, journalctl --list-boots shows only the current boot even though the server rebooted several times. The administrator wants journals kept across reboots. Which change achieves this on RHEL 10?

- A. Enable the rsyslog service so journald writes its binary files to /var/log.
- B. Set Storage=persistent in a journald.conf drop-in and restart systemd-journald.
- C. Set Storage=volatile in a journald.conf drop-in and restart systemd-journald.
- D. Run journalctl --flush once so the runtime journal is never rotated again.

**Answer:** B

**Explanation:** With Storage=persistent, journald creates /var/log/journal and keeps journals on disk across reboots; the default auto mode also persists once that directory exists. volatile keeps journals only in /run, rsyslog writes its own text log files rather than the binary journal, and --flush moves the current runtime journal once without changing the storage setting.

### Question 5 of 10

Which /etc/fstab line mounts the ext4 file system labelled backups on /backups at boot?

- A. LABEL=backups /backups xfs defaults 0 0
- B. PARTLABEL=/backups ext4 backups defaults 0 0
- C. NAME=backups /backups ext4 defaults 0 0
- D. LABEL=backups /backups ext4 defaults 0 0

**Answer:** D

**Explanation:** LABEL= selects a file system by its label, followed by the mount point, type and options. Declaring the type as xfs makes the mount fail because the file system is ext4, NAME is not a supported fstab tag, and the PARTLABEL line both refers to a GPT partition name and puts the fields in the wrong order.

### Question 6 of 10

Users' home directories are exported as nfs.lab.example.com:/homes/<username>, and they must be mounted on demand under /remote/<username> for any user. Which indirect map entry in /etc/auto.remote achieves this, given the master map entry /remote /etc/auto.remote?

- A. users -rw,sync nfs.lab.example.com:/homes/$USER
- B. /remote/* -rw,sync nfs.lab.example.com:/homes/
- C. default -rw,sync nfs.lab.example.com:/homes/&
- D. * -rw,sync nfs.lab.example.com:/homes/&

**Answer:** D

**Explanation:** In an indirect map the asterisk key matches any requested subdirectory, and the ampersand in the location is replaced by that key. A literal key such as default matches only a subdirectory with that exact name, indirect map keys are relative names rather than full paths, and $USER would be expanded in the automount daemon's environment rather than per requesting user.

### Question 7 of 10

An administrator changed GRUB_TIMEOUT in /etc/default/grub on a RHEL 10 system. Which command regenerates the GRUB configuration so the change takes effect, on both BIOS and UEFI systems?

- A. grubby --update-kernel=ALL --timeout
- B. grub2-mkconfig -o /etc/default/grub
- C. grub2-install --timeout /boot/grub2
- D. grub2-mkconfig -o /boot/grub2/grub.cfg

**Answer:** D

**Explanation:** Since RHEL 9 the main configuration file is /boot/grub2/grub.cfg on both firmware types, and grub2-mkconfig regenerates it from /etc/default/grub. Writing output over /etc/default/grub destroys the source file, grub2-install reinstalls the boot loader without a timeout option, and grubby edits boot entries rather than global menu settings.

### Question 8 of 10

An interface eth1 must receive the static IPv4 address 192.168.10.20/24 with gateway 192.168.10.1 through a new NetworkManager connection named static-eth1. Which command creates it?

- A. ip addr add 192.168.10.20/24 dev eth1 && ip route add default via 192.168.10.1 name static-eth1
- B. nmcli dev set eth1 ipv4.method manual ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 con-name static-eth1
- C. nmcli con add type ethernet con-name static-eth1 ifname eth1 ipv4.method auto ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1
- D. nmcli con add type ethernet con-name static-eth1 ifname eth1 ipv4.method manual ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1

**Answer:** D

**Explanation:** nmcli con add with ipv4.method manual creates a persistent connection profile using the static address and gateway. Method auto uses DHCP and treats the address only as an extra, nmcli dev set changes device properties such as autoconnect and managed state rather than IP settings, and ip commands are not persistent and do not create a connection profile.

### Question 9 of 10

Members of the group admins must be able to run any command as any user through sudo after entering their own password. Which line in a file under /etc/sudoers.d achieves this?

- A. %admins ALL=(ALL) ALL
- B. %admins localhost=/bin/bash
- C. admins ALL=(ALL:ALL) ALL
- D. %admins ALL=(ALL) NOPASSWD: ALL

**Answer:** A

**Explanation:** A leading percent sign refers to a group, and ALL=(ALL) ALL allows every command as any user on any host, with password authentication. Without the percent sign the rule applies to a user named admins, NOPASSWD removes the password prompt that is required here, and the last rule only permits running /bin/bash on a host called localhost.

### Question 10 of 10 (choose 2)

A service fails only when SELinux is enforcing. Which two commands help identify the denial and the policy change that would allow it? (Choose two.)

- A. restorecon -n /etc/selinux
- B. sealert -a /var/log/audit/audit.log
- C. setenforce 0
- D. chcon -t unconfined_t /usr/sbin/service
- E. ausearch -m AVC -ts recent

**Answer:** B, E

**Explanation:** ausearch -m AVC shows recent access vector cache denials, and sealert from setroubleshoot-server analyses them and suggests fixes such as a Boolean or file context. setenforce 0 hides the denials instead of explaining them, restorecon -n on the policy directory checks unrelated files, and relabelling a binary as unconfined is an unsafe workaround rather than a diagnosis.

Ready for a timed run? Take the free 15-question RHCSA mini exam: https://devopscodelab.com/app/exams/redhat-ex200/mini/

DevOpsCode Lab is not affiliated with Red Hat. RHCSA and related names are trademarks of their owners. We write every question ourselves; these are not real exam questions.
