CompTIA Linux+ Practice Questions: Security

40 free, exam-style CompTIA Linux+ (XK0-006) practice questions covering Security. Each question shows the correct answer and a clear explanation. Ready for the real thing? Take the full timed quiz below.

🚀 Take the full CompTIA Linux+ quiz 📘 CompTIA Linux+ study guide

Q1. What is the default SSH configuration file location?

Explanation: sshd_config controls the SSH server settings. Learn more.

Q2. Which file controls sudo privileges?

Explanation: sudoers defines user/group sudo permissions. Learn more.

Q3. Which command restores default SELinux file contexts?

Explanation: restorecon resets SELinux contexts based on policy. Learn more.

Q4. What is the purpose of /etc/login.defs?

Explanation: Sets defaults for useradd like password aging and UID ranges. Learn more.

Q5. Which directory contains Kerberos configuration files?

Explanation: /etc/krb5.conf is the main Kerberos config file. Learn more.

Q6. Which firewall frontend uses zones?

Explanation: firewalld manages zones (public, internal, etc.) for dynamic rules. Learn more.

Q7. What is the purpose of /etc/hosts.allow?

Explanation: TCP Wrappers use hosts.allow/hosts.deny for service access control. Learn more.

Q8. What is the purpose of 'visudo'?

Explanation: visudo locks the sudoers file and checks syntax. Learn more.

Q9. Which file controls PAM authentication?

Explanation: PAM uses service-specific configs in /etc/pam.d/. Learn more.

Q10. Which command generates SSH keys?

Explanation: ssh-keygen creates public/private key pairs. Learn more.

Q11. What does 'find / -perm /4000' locate?

Explanation: perm /4000 matches files with SUID bit set. Learn more.

Q12. Which file controls sudo lecture messages?

Explanation: sudoers uses 'lecture' directive for educational messages. Learn more.

Q13. Which command decrypts a LUKS partition?

Explanation: luksOpen unlocks encrypted devices for mapping. Learn more.

Q14. Which file controls SSH client settings?

Explanation: Client settings: global (/etc/ssh/ssh_config) and user (~/.ssh/config). Learn more.

Q15. What is the purpose of 'passwd -l'?

Explanation: Lock account by prepending '!' to password hash. Learn more.

Q16. What is the purpose of 'visudo'?

Explanation: Locks sudoers file and validates syntax. Learn more.

Q17. What does 'ssh-copy-id' do?

Explanation: Installs public key in remote ~/.ssh/authorized_keys. Learn more.

Q18. Which file controls PAM password policies?

Explanation: All contribute to password policy configuration. Learn more.

Q19. What is the purpose of the 'auditd' service?

Explanation: Linux audit subsystem logs security-relevant events. Learn more.

Q20. Which command shows SELinux boolean values?

Explanation: getsebool -a lists all SELinux booleans. Learn more.

Q21. What is the purpose of '/etc/securetty'?

Explanation: Restricts terminals where root can log in directly. Learn more.

Q22. Which command decrypts an OpenSSL-encrypted file?

Explanation: openssl enc handles symmetric encryption/decryption. Learn more.

Q23. What does 'firewall-cmd --permanent --add-rich-rule' do?

Explanation: Rich rules allow advanced firewalld configurations. Learn more.

Q24. Which file controls PAM password complexity?

Explanation: Multiple files contribute to password policies. Learn more.

Q25. Which file defines sudo lecture messages?

Explanation: sudoers uses 'lecture' parameter. Learn more.

Q26. What is the purpose of 'aide'?

Explanation: Advanced Intrusion Detection Environment monitors file changes. Learn more.

Q27. What is the purpose of 'apparmor_status'?

Explanation: Displays enforcement status of AppArmor profiles. Learn more.

Q28. Which command encrypts swap space?

Explanation: Swap encryption requires manual setup via dm-crypt/LUKS. Learn more.

Q29. Which command changes the SELinux context of a file?

Explanation: chcon changes SELinux security context labels on files. Learn more.

Q30. Which command safely edits the sudoers file with syntax checking?

Explanation: visudo locks and validates the sudoers file to reduce the risk of syntax errors that break sudo access. Learn more.

Q31. Which command shows recent authentication-related log entries on a systemd host?

Explanation: journalctl can filter logs by fields such as command name, making SSH authentication investigation easier. Learn more.

Q32. Which command locks a Linux user account password?

Explanation: passwd -l locks the password for an account, preventing password-based login. Learn more.

Q33. Which command adds a rule to allow SSH with firewalld?

Explanation: firewall-cmd manages firewalld rules, and --add-service=ssh permits the predefined SSH service. Learn more.

Q34. Which command changes the active SELinux mode temporarily?

Explanation: setenforce changes SELinux enforcing or permissive mode until reboot or configuration change. Learn more.

Q35. Which command restores default SELinux contexts on files?

Explanation: restorecon reapplies default SELinux context labels based on policy. Learn more.

Q36. Which command reports whether UEFI Secure Boot is enabled on a Linux system?

Explanation: mokutil --sb-state queries the platform and reports the current Secure Boot state. Learn more.

Q37. Which command displays the complete active nftables ruleset?

Explanation: nft list ruleset prints the active nftables tables, chains, rules, sets, and related objects. Learn more.

Q38. Which firewalld command displays the active zone's interfaces, services, ports, and rich rules?

Explanation: firewall-cmd --list-all summarizes the configuration of the active or selected firewalld zone. Learn more.

Q39. A web file has the wrong SELinux context after being moved from a home directory. Which command restores the expected policy-defined context?

Explanation: restorecon applies the default SELinux context defined by policy for the file path. Learn more.

Q40. Which command searches the Linux audit log specifically for recent SELinux AVC denial records?

Explanation: ausearch queries audit records, and the AVC message type filters for SELinux access-vector-cache denials. Learn more.

More CompTIA Linux+ practice topics