RHCSA
Free RHCSA practice questions
10 questions from our RHCSA practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Understand and use essential tools
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?
- Agrep -Ev '^(#|$)' /etc/ssh/sshd_config Correct answer
- Bgrep -E '^#|^$' /etc/ssh/sshd_config
- Cgrep -v '#' /etc/ssh/sshd_config | grep -v ' '
- Dgrep -c -v '^#' /etc/ssh/sshd_config
Answer and 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, Manage software
A dnf update performed an hour ago broke an application, and the administrator wants to revert exactly that transaction. Which approach is correct?
- ARun rpm -Va to restore the files that the transaction modified to their earlier contents.
- BFind the transaction ID with dnf history list, then run dnf history undo with that ID. Correct answer
- CRun dnf downgrade with no arguments to return every package to its previous release.
- DRun dnf history rollback 0 to return the system to the state at installation time.
Answer and 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, Create simple shell scripts
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 Correct answer
Answer and 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, Operate running systems
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?
- AEnable the rsyslog service so journald writes its binary files to /var/log.
- BSet Storage=persistent in a journald.conf drop-in and restart systemd-journald. Correct answer
- CSet Storage=volatile in a journald.conf drop-in and restart systemd-journald.
- DRun journalctl --flush once so the runtime journal is never rotated again.
Answer and 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, Configure local storage
Which /etc/fstab line mounts the ext4 file system labelled backups on /backups at boot?
- ALABEL=backups /backups xfs defaults 0 0
- BPARTLABEL=/backups ext4 backups defaults 0 0
- CNAME=backups /backups ext4 defaults 0 0
- DLABEL=backups /backups ext4 defaults 0 0 Correct answer
Answer and 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, Create and configure file systems
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?
- Ausers -rw,sync nfs.lab.example.com:/homes/$USER
- B/remote/* -rw,sync nfs.lab.example.com:/homes/
- Cdefault -rw,sync nfs.lab.example.com:/homes/&
- D* -rw,sync nfs.lab.example.com:/homes/& Correct answer
Answer and 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, Deploy, configure, and maintain systems
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?
- Agrubby --update-kernel=ALL --timeout
- Bgrub2-mkconfig -o /etc/default/grub
- Cgrub2-install --timeout /boot/grub2
- Dgrub2-mkconfig -o /boot/grub2/grub.cfg Correct answer
Answer and 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, Manage basic networking
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?
- Aip addr add 192.168.10.20/24 dev eth1 && ip route add default via 192.168.10.1 name static-eth1
- Bnmcli dev set eth1 ipv4.method manual ipv4.addresses 192.168.10.20/24 ipv4.gateway 192.168.10.1 con-name static-eth1
- Cnmcli 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
- Dnmcli 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 Correct answer
Answer and 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, Manage users and groups
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 Correct answer
- B%admins localhost=/bin/bash
- Cadmins ALL=(ALL:ALL) ALL
- D%admins ALL=(ALL) NOPASSWD: ALL
Answer and 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, Manage security. 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.)
- Arestorecon -n /etc/selinux
- Bsealert -a /var/log/audit/audit.log Correct answer
- Csetenforce 0
- Dchcon -t unconfined_t /usr/sbin/service
- Eausearch -m AVC -ts recent Correct answer
Answer and 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.