RHCSA RHCSA Linux System Administration 2 — Questions and Answers
Question 1: Which command creates a new logical volume named 'data' of size 5GB in volume group 'vg0'?
- lvcreate -L 5G -n data vg0 (Correct answer)
- lvcreate -s 5G -n data vg0
- vgcreate -L 5G -n data vg0
- lvextend -L 5G -n data vg0
Correct answer: lvcreate -L 5G -n data vg0
lvcreate -L specifies size and -n specifies the logical volume name within the volume group.
Question 2: What does the command 'chage -M 90 alice' do?
- Sets alice's maximum password age to 90 days (Correct answer)
- Sets alice's minimum password age to 90 days
- Locks alice's account for 90 days
- Sets account expiry to 90 days from now
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 3: Which SELinux command restores default file context labels recursively on /var/www/html?
- restorecon -Rv /var/www/html (Correct answer)
- semanage fcontext -a /var/www/html
- chcon -R /var/www/html
- setsebool -P /var/www/html
Correct answer: restorecon -Rv /var/www/html
restorecon -R applies recursively and -v provides verbose output, restoring default SELinux contexts.
Question 4: A user needs to run 'systemctl restart httpd' without a password via sudo. Which sudoers entry is correct?
- alice ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd (Correct answer)
- alice ALL=(ALL) /bin/systemctl restart httpd NOPASSWD
- alice ALL NOPASSWD=(ALL) /bin/systemctl restart httpd
- NOPASSWD: alice ALL=(ALL) /bin/systemctl restart httpd
Correct answer: alice ALL=(ALL) NOPASSWD: /bin/systemctl restart httpd
The NOPASSWD tag must appear before the command specification in a sudoers rule.
Question 5: Which command displays all active firewalld zones and their assigned interfaces?
- firewall-cmd --get-active-zones (Correct answer)
- firewall-cmd --list-all-zones
- firewall-cmd --list-zones
- firewall-cmd --info-zones
Correct answer: firewall-cmd --get-active-zones
--get-active-zones shows only zones that have interfaces or sources bound to them.
Question 6: What is the effect of setting 'net.ipv4.ip_forward = 1' in /etc/sysctl.conf?
- Enables the system to forward IPv4 packets between interfaces (Correct answer)
- Allows the system to accept ICMP redirects
- Enables IPv4 fragmentation forwarding only
- Disables reverse path filtering
Correct answer: Enables the system to forward IPv4 packets between interfaces
ip_forward = 1 enables kernel-level packet forwarding, making the host act as a router.
Question 7: Which command permanently adds the 'http' service to the 'public' firewalld zone?
- firewall-cmd --zone=public --add-service=http --permanent (Correct answer)
- firewall-cmd --zone=public --add-service=http
- firewall-cmd --permanent --zone=public --open-service=http
- firewall-cmd --add-service=http --zone=public --save
Correct answer: firewall-cmd --zone=public --add-service=http --permanent
The --permanent flag writes the rule to the zone configuration file so it persists across reloads.
Which command creates a new logical volume named 'data' of size 5GB in volume group 'vg0'?