RHCSA (Red Hat Certified System Administrator) Exam — Questions and Answers
Question 1: Which configuration file defines the DNS search domain and nameservers for a RHEL system?
- /etc/hosts
- /etc/resolv.conf (Correct answer)
- /etc/nsswitch.conf
- /etc/sysconfig/network
Correct answer: /etc/resolv.conf
/etc/resolv.conf contains the `nameserver` and `search` directives used by the resolver library.
Question 2: Which command enables IP masquerading on the 'external' zone permanently?
- firewall-cmd --zone=external --enable-masquerade --permanent
- firewall-cmd --zone=external --masquerade=yes --permanent
- firewall-cmd --zone=external --nat=masquerade --permanent
- firewall-cmd --zone=external --add-masquerade --permanent (Correct answer)
Correct answer: firewall-cmd --zone=external --add-masquerade --permanent
--add-masquerade enables NAT masquerading in the specified zone so outgoing packets use the interface's IP.
Question 3: Which command reloads systemd's configuration without rebooting after you add a new unit file?
- systemctl refresh
- systemctl restart systemd
- systemctl reload
- systemctl daemon-reload (Correct answer)
Correct answer: systemctl daemon-reload
`systemctl daemon-reload` rescans all unit files and reloads systemd's configuration in place.
Question 4: Which of the following commands would a system administrator use to view the most recent login times for all users on the system?
- who
- users
- lastlog (Correct answer)
- id
Correct answer: lastlog
The `lastlog` command formats and prints the contents of the `/var/log/lastlog` file, which records the most recent login for each user. The `who` command shows who is currently logged on. The `users` command lists the usernames of currently logged-in users. The `id` command displays user and group ID information for a specified user, not login times.
Question 5: What is the effect of running `chmod g+s /shared/dir`?
- The sticky bit is set on the directory
- Files in the dir inherit the group of the directory (Correct answer)
- The directory is only accessible by the group
- Files in the dir inherit the owner's UID
Correct answer: Files in the dir inherit the group of the directory
The setgid bit on a directory causes new files created inside to inherit the directory's group rather than the creator's primary group.
Question 6: Which systemd unit type is used to mount a filesystem defined in /etc/fstab at a specific path?
- .path
- .mount (Correct answer)
- .service
- .automount
Correct answer: .mount
`.mount` units represent filesystem mount points and correspond to entries in `/etc/fstab`.
Question 7: Which command displays the last 20 lines of a file named 'syslog'?
- tail -20 syslog (Correct answer)
- head -20 syslog
- less -20 syslog
- cat -20 syslog
Correct answer: tail -20 syslog
The tail command with -N flag outputs the last N lines of a file.
Question 8: Which command displays the routing table on a RHEL system?
- route print
- ip route show (Correct answer)
- ifconfig -r
- netstat -i
Correct answer: ip route show
`ip route show` (or `ip r`) displays the kernel routing table using the modern iproute2 suite.
Question 9: Which command makes firewalld configuration changes survive a system reboot?
- firewall-cmd --reload
- systemctl restart firewalld
- firewall-cmd --save
- firewall-cmd --permanent followed by --reload (Correct answer)
Correct answer: firewall-cmd --permanent followed by --reload
Using --permanent saves the rule to disk; --reload applies the saved config so it is active immediately and persists after reboot.
Question 10: Which command removes a user account AND their home directory and mail spool?
- userdel alice
- passwd -l alice
- userdel -r alice (Correct answer)
- usermod -d /dev/null alice
Correct answer: userdel -r alice
userdel -r removes the user's home directory and mail spool in addition to deleting the account.
Question 11: Which command would you use to add port 8888 to the http_port_t SELinux type so Apache can listen on it?
- chcon -t http_port_t :8888
- semanage fcontext -a -t http_port_t -p tcp 8888
- semanage port -a -t http_port_t -p tcp 8888 (Correct answer)
- setsebool httpd_use_port 8888
Correct answer: semanage port -a -t http_port_t -p tcp 8888
semanage port -a adds a port-to-type mapping; without it, Apache is denied the bind permission on non-standard ports.
Question 12: Which command temporarily sets a single process's SELinux domain for troubleshooting without modifying policy?
- runcon -t vsftpd_t -- /usr/sbin/vsftpd (Correct answer)
- secon --type vsftpd_t
- chcon -t vsftpd_t /usr/sbin/vsftpd
- semanage permissive -a vsftpd_t
Correct answer: runcon -t vsftpd_t -- /usr/sbin/vsftpd
runcon executes a command in a specified security context, useful for testing without policy changes.
Question 13: Which command searches for the string 'error' case-insensitively in all .log files under /var/log?
- grep -ri 'error' /var/log/ (Correct answer)
- find /var/log -name '*.log' | xargs grep 'error'
- locate -i 'error' /var/log/
- grep -ri 'error' /var/log/*.log
Correct answer: grep -ri 'error' /var/log/
`grep -r` recurses through directories and `-i` makes the search case-insensitive, covering all .log files.
Question 14: Which configuration file defines system-wide resource limits (e.g., max open files) for PAM-authenticated sessions?
- /etc/pam.d/common-session
- /etc/systemd/system.conf
- /etc/sysctl.conf
- /etc/security/limits.conf (Correct answer)
Correct answer: /etc/security/limits.conf
/etc/security/limits.conf sets per-user and per-group limits enforced by the pam_limits module at login.
Question 15: Which SSH client config file allows you to define aliases and per-host settings for SSH connections?
- /etc/ssh/client.conf
- ~/.ssh/ssh_config
- ~/.ssh/hosts
- ~/.ssh/config (Correct answer)
Correct answer: ~/.ssh/config
The `~/.ssh/config` file lets users define `Host` blocks with per-host settings like IdentityFile, Port, and User.
Question 16: Which command adds a swap partition at /dev/sdb2 and activates it immediately without a reboot?
- mkfs.swap /dev/sdb2 && mount -t swap /dev/sdb2
- fdisk --swap /dev/sdb2
- mkswap /dev/sdb2 && swapon /dev/sdb2 (Correct answer)
- swapon --create /dev/sdb2
Correct answer: mkswap /dev/sdb2 && swapon /dev/sdb2
mkswap formats the partition as swap space, and swapon activates it immediately for use by the kernel.
Question 17: Which file contains the system-wide SSH server configuration on RHEL?
- /etc/ssh/ssh_config
- /etc/openssh/sshd_config
- /etc/ssh/sshd_config (Correct answer)
- /etc/sshd.conf
Correct answer: /etc/ssh/sshd_config
The SSH daemon reads its server-side configuration from `/etc/ssh/sshd_config` on RHEL and most Linux distributions.
Question 18: On a Linux computer, which of the following files is used to initialize a system-wide environment?
- /etc/startup
- tc/group
- /etc/syslog.conf
- /etc/profile (Correct answer)
Correct answer: /etc/profile
The file used to initialize a computer-wide environment on a Linux computer is /etc/profile. <br> <br> The /etc/profile file is a system-wide initialization script that is executed during the login process for all users on the system. It sets up the environment variables and executes commands that need to be run for every user's shell session.
Question 19: What UID range is typically reserved for system/service accounts on RHEL?
- 1-499
- 1000-4999
- 0-99
- 0-999 (Correct answer)
Correct answer: 0-999
On RHEL, UIDs 0-999 are reserved for system accounts, with regular users starting at UID 1000 by default.
Question 20: What is the purpose of `set -e` at the beginning of a Bash script?
- Enforce read-only variables
- Enable extended globbing
- Echo every command before running it
- Exit the script immediately if any command returns a non-zero status (Correct answer)
Correct answer: Exit the script immediately if any command returns a non-zero status
`set -e` causes the script to exit immediately when any command exits with a non-zero (failure) status.
Question 21: What does the redirection operator '>>' do?
- Creates a new file and writes stdout to it
- Appends stdout to a file without overwriting (Correct answer)
- Redirects stderr to a file
- Overwrites a file with stdout
Correct answer: Appends stdout to a file without overwriting
>> appends standard output to the end of a file, preserving existing content.
Question 22: As a system administrator, you want to ensure that all newly created user accounts automatically have a default `.bash_profile` and a `README.txt` file in their home directory. Where should you place these template files?
- /home
- /etc/skel (Correct answer)
- /etc/login.defs
- /etc/default/useradd
Correct answer: /etc/skel
The `/etc/skel` directory serves as a skeleton directory. Files and directories within `/etc/skel` are automatically copied to a new user's home directory when the account is created with the `useradd` command. `/etc/default/useradd` and `/etc/login.defs` contain default settings for user creation but not file templates. `/home` is the parent directory for user home directories but does not serve as a template.
Question 23: What is the primary security advantage of running Podman containers in rootless mode?
- Rootless containers have access to all host namespaces
- Containers run faster without root overhead
- Container processes run as a non-privileged user, reducing host compromise risk (Correct answer)
- Rootless mode enables container-to-container networking
Correct answer: Container processes run as a non-privileged user, reducing host compromise risk
Rootless containers run as a non-root user on the host, so a container escape does not grant root access to the host system.
Question 24: Which firewalld zone is designed for computers in the same local network that you mostly trust?
- trusted
- work
- internal
- home (Correct answer)
Correct answer: home
The 'home' zone is for home networks where you trust most other computers and selected incoming connections are accepted.
Question 25: Which command removes a stopped container named 'myapp' in Podman?
- podman remove myapp
- podman delete myapp
- podman container purge myapp
- podman rm myapp (Correct answer)
Correct answer: podman rm myapp
'podman rm myapp' removes a stopped container; use '-f' to force-remove a running container.
Question 26: An administrator runs 'rpm -V httpd' and sees 'S.5....T. /etc/httpd/conf/httpd.conf'. What does the '5' indicate?
- File permissions differ
- MD5 checksum differs from the package (Correct answer)
- File size has changed
- SELinux context differs
Correct answer: MD5 checksum differs from the package
In rpm -V output, '5' means the MD5 checksum (digest) of the file differs from what the package recorded at install time.
Question 27: What is a DNF module 'profile'?
- A predefined set of packages within a module stream for a specific use case (Correct answer)
- A saved state of enabled module streams
- A user-specific set of package preferences
- A performance tuning preset for the module
Correct answer: A predefined set of packages within a module stream for a specific use case
A module profile is a curated list of packages from a stream optimized for a role (e.g., 'minimal', 'server', 'client') that can be installed together.
Question 28: What does the last field (pass) in an /etc/fstab entry control?
- The priority of the mount operation
- The number of times the filesystem can be mounted
- The order in which fsck checks filesystems at boot (Correct answer)
- Whether the filesystem is automatically unmounted on shutdown
Correct answer: The order in which fsck checks filesystems at boot
The pass field controls the order in which fsck checks filesystems at boot; 0 means skip, 1 is for root, 2 for others.
Question 29: Which of the following `nmcli` commands correctly configures a static IPv4 address, gateway, and DNS server for a connection named 'eth0'?
- nmcli con mod eth0 set ipv4.address 192.168.1.100/24 gw4 192.168.1.1 dns 8.8.8.8
- nmcli device mod eth0 ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8 ipv4.method static
- nmcli con add con-name eth0 type ethernet ifname eth0 ip4 192.168.1.100/24 gw4 192.168.1.1
- nmcli con mod eth0 ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8 ipv4.method manual (Correct answer)
Correct answer: nmcli con mod eth0 ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.dns 8.8.8.8 ipv4.method manual
The correct command to modify an existing NetworkManager connection is `nmcli connection modify` (or `con mod`). The static IP address and subnet mask are set with `ipv4.addresses`, the gateway with `ipv4.gateway`, and the DNS server with `ipv4.dns`. Crucially, `ipv4.method` must be set to `manual` to disable DHCP and use the static configuration.
Question 30: Which systemd unit type is automatically generated from /etc/fstab entries to manage mounts?
- .mount units (Correct answer)
- .service units
- .socket units
- .path units
Correct answer: .mount units
systemd-fstab-generator converts /etc/fstab entries into .mount units that systemd uses to manage filesystems.
Question 31: Which directive in a unit file's `[Service]` section sets environment variables for the process?
- SetEnv=
- EnvSet=
- EnvFile=
- Environment= (Correct answer)
Correct answer: Environment=
`Environment=` sets key=value environment variables directly in the unit file's `[Service]` section.
Question 32: You are employed at TestGeeks Inc. as a network administrator. The business's network is built on Linux. You have produced a 100-line document using the VI tool. In the first 50 lines of the paper, all instances of "net" should be changed to "Net." Which command from the list below will you use?
- :1,50 s/net/Net/g (Correct answer)
- :1,100 s/net/Net/g
- :1,$ s/net/Net/g
- :s/net/Net/g
Correct answer: :1,50 s/net/Net/g
In order to replace all the occurrences of "net" with "Net" in the first fifty lines of the file, you will have to execute the following command: <br> :1,50 s/net/Net/g. This command is issued in the command mode of the VI utility. 1,50 defines the current document's initial and final line numbers where the command will execute. The s/ switch with the net/Net/g option will globally replace all the occurrences of "net" with "Net".
Question 33: What does 'ls -lh' add over 'ls -l'?
- Displays file sizes in human-readable format (KB, MB, GB) (Correct answer)
- Lists files sorted by size
- Shows hidden files
- Displays inode numbers
Correct answer: Displays file sizes in human-readable format (KB, MB, GB)
The -h flag makes sizes human-readable by using units like K, M, and G instead of raw bytes.
Question 34: Which command creates a new XFS filesystem on /dev/sdc1?
- format.xfs /dev/sdc1
- mkfs -t xfs /dev/sdc1 only
- mkfs.xfs /dev/sdc1 (Correct answer)
- xfs_create /dev/sdc1
Correct answer: mkfs.xfs /dev/sdc1
mkfs.xfs is the standard command to create an XFS filesystem on a specified block device.
Question 35: The command 'ls -Z /var/www/html/app.php' shows 'user_home_t'. What is the quickest correct fix?
- mv /var/www/html/app.php /tmp/ && mv /tmp/app.php /var/www/html/
- chcon -t httpd_sys_content_t /var/www/html/app.php
- restorecon /var/www/html/app.php (Correct answer)
- semanage fcontext -a -t httpd_sys_content_t '/var/www/html/app.php' && restorecon /var/www/html/app.php
Correct answer: restorecon /var/www/html/app.php
restorecon resets the file to the context already defined for /var/www/html in the policy database, which is httpd_sys_content_t.
Question 36: What does the command 'wc -l filename' report?
- Number of lines in the file (Correct answer)
- Number of words in the file
- Number of characters in the file
- File size in bytes
Correct answer: Number of lines in the file
The wc -l option counts and displays the number of newline characters (lines) in a file.
Question 37: What happens when you run 'chmod u+s' on an executable binary?
- The binary runs with the file owner's privileges regardless of who executes it (Correct answer)
- The binary inherits the sticky bit
- The binary is restricted to root execution only
- The binary runs with the executing user's group privileges
Correct answer: The binary runs with the file owner's privileges regardless of who executes it
The setuid bit causes an executable to run with the file owner's UID rather than the caller's UID.
Question 38: What cron schedule expression runs a job every day at 2:30 AM?
- 2 30 * * *
- * * 2 30 *
- 30 * 2 * *
- 30 2 * * * (Correct answer)
Correct answer: 30 2 * * *
The expression `30 2 * * *` means minute=30, hour=2, any day, any month, any weekday — i.e., 2:30 AM daily.
Question 39: You need to move all data off /dev/sdb1 (which is in vg0) to other PVs before removal. Which command does this?
- lvmigrate /dev/sdb1
- pvmove /dev/sdb1 (Correct answer)
- pvtransfer /dev/sdb1
- vgmove vg0 /dev/sdb1
Correct answer: pvmove /dev/sdb1
pvmove relocates all logical extents from the specified physical volume to other PVs in the same VG.
Question 40: When using lvextend with the '-r' flag, what additional action does it perform automatically?
- Runs fsck on the filesystem
- Remounts the filesystem read-write
- Reboots the system to apply changes
- Resizes the filesystem on the LV (Correct answer)
Correct answer: Resizes the filesystem on the LV
The -r (--resizefs) flag causes lvextend to automatically resize the filesystem after extending the LV.
Question 41: A volume group shows 'partial' status. What does this indicate?
- The VG is partially activated
- The VG has less than 50% free space
- One or more PVs in the VG are missing or unavailable (Correct answer)
- The VG has been exported but not imported
Correct answer: One or more PVs in the VG are missing or unavailable
A 'partial' VG means at least one physical volume member is missing, making some LV data inaccessible.
Question 42: How do you configure a NetworkManager connection to use the static IP 192.168.1.50/24 with gateway 192.168.1.1?
- nmcli con add ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1
- nmcli con mod eth0 ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.method manual (Correct answer)
- nmtui set eth0 192.168.1.50/24 gw 192.168.1.1
- ip addr add 192.168.1.50/24 dev eth0 && ip route add default via 192.168.1.1
Correct answer: nmcli con mod eth0 ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 ipv4.method manual
nmcli con mod modifies an existing connection profile; ipv4.method manual disables DHCP and applies the static address.
Question 43: Which command displays detailed information about an installed RPM package including its description and install date?
- rpm -qd <package>
- rpm -qi <package> (Correct answer)
- rpm -qR <package>
- rpm -ql <package>
Correct answer: rpm -qi <package>
rpm -qi shows package info (name, version, description, install date); -ql lists files, -qd lists docs, -qR lists dependencies.
Question 44: In Bash, what does the `test -f /etc/passwd` command check?
- Whether /etc/passwd is executable
- Whether /etc/passwd is a directory
- Whether /etc/passwd exists and is a regular file (Correct answer)
- Whether /etc/passwd has read permission
Correct answer: Whether /etc/passwd exists and is a regular file
The `-f` flag in `test` returns true if the given path exists and is a regular (non-directory) file.
Question 45: Which command displays real-time I/O statistics per block device every 2 seconds?
- blkstat 2
- iostat -xz 2 (Correct answer)
- iotop -b 2
- vmstat -d 2
Correct answer: iostat -xz 2
iostat -x shows extended statistics per device and -z suppresses devices with no activity; the interval is 2 seconds.
Question 46: What is the correct NFS mount entry in /etc/fstab to mount 192.168.1.10:/exports/data at /mnt/data with read-write and auto-mount?
- /mnt/data 192.168.1.10:/exports/data nfs rw 0 0
- 192.168.1.10:/exports/data /mnt/data nfs noauto 0 0
- 192.168.1.10:/exports/data /mnt/data nfs rw,_netdev 0 0 (Correct answer)
- 192.168.1.10:/exports/data /mnt/data nfs4 defaults 0 0
Correct answer: 192.168.1.10:/exports/data /mnt/data nfs rw,_netdev 0 0
_netdev tells systemd to mount after network is available, which is required for network filesystems.
Question 47: A directory listing shows 'drwxrwt---'. What special bit is set?
- ACL bit
- setgid bit
- Sticky bit (Correct answer)
- setuid bit
Correct answer: Sticky bit
A lowercase 't' in the other-execute position indicates the sticky bit is set and execute is also enabled.
Question 48: What does the command 'chage -M 90 alice' do?
- Sets account expiry to 90 days from now
- Locks alice's account for 90 days
- Sets alice's maximum password age to 90 days (Correct answer)
- Sets alice's minimum password age to 90 days
Correct answer: Sets alice's maximum password age to 90 days
chage -M sets the maximum number of days before a password must be changed.
Question 49: A system fails to boot because of an incorrect /etc/fstab entry. Which kernel parameter allows you to boot into a rescue shell to fix it?
- rd.break (Correct answer)
- systemd.unit=rescue.target
- init=/bin/sh
- single
Correct answer: rd.break
rd.break interrupts the boot process before the root filesystem is mounted, providing a rescue shell to fix fstab issues.
Question 50: After noticing a file has extended ACLs, indicated by a `+` sign in the `ls -l` output, a system administrator wants to completely remove all ACL entries and revert to standard POSIX permissions. Which command should be used?
- setfacl -x /path/to/file
- setfacl -k /path/to/file
- setfacl -b /path/to/file (Correct answer)
- chmod 755 /path/to/file
Correct answer: setfacl -b /path/to/file
The `setfacl` command with the `-b` (or `--remove-all`) option is the correct way to strip all extended ACL entries from a file or directory, leaving only the base permissions for the owner, group, and others. The `+` sign in the `ls -l` output will disappear after this command is successfully executed.
Question 51: A DNF module stream is enabled but you want to switch to a different stream. What must you do first?
- dnf module disable <module>
- dnf module remove <module>
- dnf module reset <module> (Correct answer)
- dnf module switch <module>
Correct answer: dnf module reset <module>
You must run 'dnf module reset <module>' to clear the active stream before enabling a different one.
RHCSA (Red Hat Certified System Administrator) Exam
The RHCSA (Red Hat Certified System Administrator) Exam exam validates essential knowledge and skills required for certification or licensure in this field.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds