Sample CompTIA Linux+ XK0-005 Practice Questions
Q: Which directory in the Linux file system hierarchy contains essential system binaries needed for single-user mode and boot?
A: /sbin — /sbin contains essential system binaries required during the boot process and for system recovery in single-user mode. /usr/bin holds general user commands, /opt is for optional software, and /var stores variable data.
Q: Which command is used to set SELinux to permissive mode temporarily?
A: setenforce 0 — setenforce 0 sets SELinux to permissive mode, where policy violations are logged but not enforced. setenforce 1 returns to enforcing mode. This change is temporary and reverts on reboot.
Q: Which line should be the first line of a bash script to specify the interpreter?
A: #!/bin/bash — #!/bin/bash is the shebang (hashbang) line that tells the kernel which interpreter to use when executing the script. It must be the very first line of the file with no preceding whitespace.
Q: Which command displays real-time system resource usage including CPU, memory, and running processes?
A: top — top provides a dynamic real-time view of system resource usage, showing CPU utilization, memory usage, load averages, and individual process details. It updates every few seconds by default.
Q: Which directory stores device files in Linux?
A: /dev — /dev contains device files (block and character devices) that represent hardware components and virtual devices. The kernel and udev create and manage these files.
Q: What type of file system is /proc in Linux?
A: A virtual/pseudo file system — /proc is a virtual (pseudo) file system that provides an interface to kernel data structures. It does not exist on disk but is generated dynamically by the kernel to expose process and system information.
Q: Which directory contains system-wide configuration files for services and applications?
A: /etc — /etc is the standard directory for host-specific system configuration files. Services like SSH, Apache, and PAM all store their configuration files here.
Q: Which directory typically contains log files on a Linux system?
A: /var/log — /var/log is the standard location for system and application log files. Services like syslog, Apache, and the kernel write their logs here.
Q: Which command installs a package on a Debian-based system using APT?
A: apt install package — The apt install command is used on Debian-based distributions (Ubuntu, Debian, Mint) to install packages from configured repositories. yum/dnf is for RHEL-based, and zypper is for SUSE-based systems.
Q: On a RHEL-based system, which command is used to install a package?
A: dnf install package — dnf (Dandified YUM) is the default package manager for RHEL 8+, CentOS Stream, Fedora, and related distributions. It replaced yum and handles dependency resolution automatically.