RHCE SELinux Administration 1 — Questions and Answers
Question 1: Which command displays the current SELinux enforcement mode?
- seinfo
- getenforce
- sestatus
- Both B and C (Correct answer)
Correct answer: Both B and C
Both `getenforce` (returns Enforcing/Permissive/Disabled) and `sestatus` (shows detailed status) display the SELinux mode.
Question 2: What SELinux mode allows policy violations but logs them without blocking?
- Enforcing
- Disabled
- Permissive (Correct answer)
- Audit
Correct answer: Permissive
In Permissive mode, SELinux logs policy violations to the audit log but does not deny access.
Question 3: Which command temporarily sets SELinux to permissive mode without a reboot?
- setenforce 0
- setenforce Permissive
- semodule -P
- Both A and B (Correct answer)
Correct answer: Both A and B
Both `setenforce 0` and `setenforce Permissive` switch SELinux to permissive mode immediately without rebooting.
Question 4: Which file must be edited to make SELinux mode changes persistent across reboots?
- /etc/selinux/policy.conf
- /etc/selinux/config (Correct answer)
- /etc/sysconfig/selinux is a symlink to this
- /etc/sysconfig/selinux
Correct answer: /etc/selinux/config
`/etc/selinux/config` is the primary configuration file for persistent SELinux mode and policy settings.
Question 5: What command displays the SELinux context of files in the current directory?
- ls -Z (Correct answer)
- ls -l
- stat --selinux
- getfattr -Z
Correct answer: ls -Z
`ls -Z` shows the SELinux security context (user:role:type:level) for each file alongside standard attributes.
Question 6: Which command restores default SELinux file contexts recursively on `/var/www/html`?
- chcon -R /var/www/html
- restorecon -Rv /var/www/html (Correct answer)
- semanage fcontext /var/www/html
- fixfiles /var/www/html
Correct answer: restorecon -Rv /var/www/html
`restorecon -Rv` restores SELinux contexts to their policy defaults recursively and shows what was changed.
Which command displays the current SELinux enforcement mode?