CompTIA Linux+ (XK0-006) practice questions

208 free questions with answers and explanations.

Practice test
  1. 51.A system administrator is deploying a new web application inside a Docker container. The application needs to persistently store user-uploaded files, and these files must remain accessible even if the container is removed or recreated. Which Docker feature is best suited for this requirement?Services and User Management
  2. 52.A pilot deployment requires a web server's HTTP service to be reachable permanently, including after the next reboot, using firewalld on a RHEL-based system. Which command sequence correctly achieves this?Security
  3. 53.A system administrator is deploying a new web application that runs inside a Docker container. The application needs to persistently store its data in a directory on the host machine, `/srv/myapp/data`, and this directory should be accessible to the container at `/app/data`. The container image is `mywebapp:latest`. Which `docker run` command option correctly configures this persistent storage?Services and User Management
  4. 54.A junior administrator is configuring a new Linux server and needs to enable a `systemd` service named `webserver.service` so that it starts automatically at boot time. Which command should be used?Services and User Management
  5. 55.During a security audit, an administrator runs 'rpm -V openssh-server' and receives the output '..5....T. c /etc/ssh/sshd_config'. What does the '5' character in that output specifically indicate?Security
  6. 56.A technician is investigating a server that takes an unusually long time to shut down. During the shutdown process, messages appear indicating that systemd is waiting for several services to stop, specifically `network.service` and `firewalld.service`, eventually timing out. Which of the following is the most appropriate initial step to diagnose why these services are failing to stop gracefully?Troubleshooting
  7. 57.A system administrator is troubleshooting a web server that is intermittently slow. They suspect that the server's network card might be experiencing errors or dropped packets at the hardware level. Which command would provide statistics about network interface errors, such as dropped packets, collisions, or overruns, that are typically indicative of physical layer or driver issues?Troubleshooting
  8. 58.A system administrator installs a new application that uses a custom systemd service named 'appdaemon.service'. After installation, the administrator attempts to start the service with 'systemctl start appdaemon.service', but it fails immediately. Upon checking 'journalctl -xe', they see an error indicating the service unit file cannot be found. What is the most likely cause?System Management
  9. 59.A system administrator is investigating a Linux server that unexpectedly rebooted. The last messages in `/var/log/messages` (or `journalctl`) before the reboot show entries indicating "Out of memory: Kill process ... or sacrifice child". Which kernel mechanism is responsible for terminating processes in such a low-memory situation?Troubleshooting
  10. 60.A developer needs to create a Python script that uses the `subprocess` module to run an external shell command and capture its standard output. The command to be executed is `ls -l /tmp`. Which of the following Python code snippets correctly executes the command and captures its output as a string?Automation, Orchestration and Scripting
  11. 61.A system administrator observes that a Linux server's CPU utilization is consistently high (near 100%) according to `top`, but no single process appears to be consuming excessive CPU. Further investigation using `pidstat -u 1` shows a high `%usr` and `%sys` for the `ksoftirqd` processes. What is the most likely cause for this behavior?Troubleshooting
  12. 62.A system administrator is writing a Bash script to process a list of user IDs. The script needs to iterate through each ID, perform a specific operation, and then report the outcome. Which of the following Bash constructs is most appropriate for iterating over a space-separated string of user IDs?Automation, Orchestration and Scripting
  13. 63.After a kernel update, a server fails to boot and drops to a `grub rescue>` prompt displaying "error: unknown filesystem". What is the most likely cause?Troubleshooting
  14. 64.A system administrator has configured a new service `mydaemon.service` to start automatically on boot. After a reboot, `systemctl status mydaemon.service` shows `Active: inactive (dead)`. Upon checking `journalctl -u mydaemon.service`, the logs indicate `Failed to start My Custom Daemon: No such file or directory`. The `ExecStart` line in the service file is `ExecStart=/usr/local/bin/mydaemon`. What is the most likely issue?Troubleshooting
  15. 65.A system administrator is hardening a new server and needs to configure firewalld to allow incoming HTTPS traffic only from the internal network (10.0.0.0/8) while blocking it from all other sources. Which of the following firewalld-cmd commands correctly implements this requirement?Security
  16. 66.An administrator is compiling and installing software from source code and wants to keep it completely separate from files managed by the distribution's package manager (dnf/apt), while still following the Filesystem Hierarchy Standard. Which directory tree is intended for this purpose?System Management
  17. 67.A user needs to send a confidential file called payroll.csv to a colleague such that only the colleague, who has shared their public key, can decrypt and read it. Which command correctly encrypts the file using GPG for that specific recipient?Security
  18. 68.A system administrator needs to troubleshoot a network connectivity issue on a Linux server. They suspect that packets might be dropped or misrouted along the path to a remote host (`remote.example.com`). Which command would best allow them to trace the network path and identify specific hops where latency increases or packets are lost?Troubleshooting
  19. 69.Users report they cannot create new files in /data even though `df -h` shows only 20% disk space used on that filesystem. Which command should the technician run next to diagnose the problem?Troubleshooting
  20. 70.A system administrator needs to troubleshoot a server that is experiencing intermittent network connectivity issues. The administrator suspects that the issue might be related to DNS resolution, specifically with the server's ability to resolve external hostnames. Which command would be most effective to test the server's configured DNS resolvers and their ability to resolve an external hostname?Troubleshooting
  21. 71.After replacing a failed hard drive, an administrator edits /etc/fstab with what they believe is the new drive's UUID and reboots. The system drops into an emergency shell with the message: "Failed to mount /data - Dependency failed for Local File Systems." Which command should the administrator run to find the correct UUID for the new drive?Troubleshooting
  22. 72.A company's security policy requires that only the users 'admin' and 'deploy' be permitted to log in via SSH to a production server, with all other local accounts denied SSH access even if their passwords are correct. Which sshd_config directive achieves this?Security
  23. 73.A developer is writing a Python script that needs to interact with a Git repository. Specifically, the script must be able to add a file to the staging area and then commit the changes. Which Python library is most suitable for programmatic Git operations?Automation, Orchestration and Scripting
  24. 74.A system administrator is troubleshooting a web server that is intermittently slow. They suspect a bottleneck in the network interface card's ability to handle traffic. Which directory in the `/proc` filesystem would provide real-time counters and statistics for network interfaces, including received/transmitted bytes, packets, and errors, without requiring external tools like `ethtool`?Troubleshooting
  25. 75.A DevOps engineer is configuring a Continuous Integration/Continuous Delivery (CI/CD) pipeline for a new microservice. They need to ensure that after a successful build and passing unit tests, the Docker image is tagged and pushed to a container registry, but only if the build originates from the 'main' branch. Which CI/CD pipeline stage and conditional logic would best achieve this requirement?Automation, Orchestration and Scripting
  26. 76.A system administrator needs to create a new group named `devteam` with a specific GID of `5000`. Which command will accomplish this?Services and User Management
  27. 77.A technician created a 2GB swap file with the commands 'fallocate -l 2G /swapfile' and 'chmod 600 /swapfile', then ran 'mkswap /swapfile'. Which command is required next to activate the swap file for immediate use?System Management
  28. 78.A developer is implementing a Python script that needs to interact with a version control system. They decide to use `gitpython` to programmatically manage a Git repository. To get started, they need to clone an existing remote repository into a local directory. Which `gitpython` method should be used to perform this operation?Automation, Orchestration and Scripting
  29. 79.A web server administrator notices that `top` shows high 'wa' (I/O wait) percentage, suggesting a disk bottleneck. However, `iostat -x` reports low `%util` (e.g., 20%) for all disks. The server is running a database that frequently accesses small files. What is the most likely reason for this discrepancy?Troubleshooting
  30. 80.A system administrator is troubleshooting a web server that is experiencing intermittent high latency when users access static content. They observe that `top` shows high `wa` (I/O wait) percentage, but `iostat` reports very high IOPS (Input/Output Operations Per Second) with low average I/O service times. What does this combination of symptoms most likely indicate?Troubleshooting
  31. 81.A technician edited /etc/default/grub on a BIOS-based server to add a new kernel parameter. Which command must be run next to regenerate the actual boot loader configuration file so the change takes effect?System Management
  32. 82.A security policy requires that the /tmp partition on a server be mounted so that no binaries can be executed from it, the setuid/setgid bits have no effect, and no device files can be created or accessed there. Which comma-separated options should the technician add to the /tmp entry in /etc/fstab?System Management
  33. 83.A security auditor needs to restrict SSH access to a Linux server so that only users from a specific IP address range (192.168.1.0/24) can connect. Which of the following directives in the SSH daemon configuration file (sshd_config) should be used to achieve this?Security
  34. 84.A system administrator is troubleshooting a server with intermittent network connectivity issues. They suspect a problem with the network interface card (NIC) driver or its parameters. Which command can be used to display detailed information about the currently loaded kernel modules, including their dependencies and parameters?System Management
  35. 85.A technician configures key-based SSH authentication for a user. When the user attempts to log in, the client displays: "UNPROTECTED PRIVATE KEY FILE!" and the connection is refused. A long listing shows `-rw-r--r-- 1 user user 1823 Jun 1 09:00 /home/user/.ssh/id_rsa`. Which command resolves the issue?Troubleshooting
  36. 86.A technician is building a new server that will use UEFI firmware instead of legacy BIOS. Which type of partition must exist on the disk to allow the system to boot GRUB under UEFI?System Management
  37. 87.A build engineer is configuring a Continuous Integration/Continuous Delivery (CI/CD) pipeline for a microservices application. Each microservice has its own Git repository and requires independent building, testing, and deployment. Which of the following CI/CD pipeline characteristics is MOST important to ensure efficient and isolated processing for each microservice?Automation, Orchestration and Scripting
  38. 88.A system administrator is investigating a Linux server that is experiencing intermittent network connectivity issues. They suspect a problem with the network interface card (NIC) driver or hardware. Which of the following commands would best provide detailed statistics about network interface errors, such as dropped packets and collisions?Troubleshooting
  39. 89.A client reports that internal applications cannot resolve www.example.com. The technician runs: `dig @8.8.8.8 www.example.com` — returns a valid answer with status: NOERROR `dig www.example.com` (using the system's default resolver) — returns status: SERVFAIL What does this comparison indicate?Troubleshooting
  40. 90.A technician wants to view detailed information about a kernel module, including its version, license, dependencies, and parameters, without actually loading it into the running kernel. Which command should be used?System Management
  41. 91.A recent 'dnf update' on a Fedora-based server introduced a broken dependency that is causing a critical service to fail. Which command reverts the system to the state before that last transaction?System Management
  42. 92.A systems administrator has been running a new AppArmor profile in complain mode for two weeks and has resolved all logged violations. The administrator now wants the profile to actively block disallowed actions rather than just log them. Which command accomplishes this?Security
  43. 93.A security engineer wants to harden a server's firewall so that any inbound traffic not explicitly matched by an existing rule is silently discarded, while all currently configured rules remain unchanged. Which command achieves this for the INPUT chain?Security
  44. 94.During the Linux boot process, after the bootloader loads the compressed kernel image into memory, which component provides a temporary, RAM-based root filesystem containing essential drivers and tools needed to mount the real root filesystem before systemd (PID 1) takes over?System Management
  45. 95.A company's security policy requires that root never be able to log in directly over SSH; all administrators must log in with their own accounts and use sudo. Which configuration change in /etc/ssh/sshd_config enforces this policy?Security
  46. 96.A technician configures a static IPv4 address on connection 'eth0' using 'nmcli con mod eth0 ipv4.addresses 192.168.10.5/24 ipv4.method manual'. Which command is needed to apply these changes without rebooting the server?System Management
  47. 97.A technician needs to load a kernel module that requires two other modules to function correctly, without manually determining and loading each dependency. Which command should be used?System Management
  48. 98.A Linux server is configured with a network interface `eth0` and a default gateway `192.168.1.1`. The server can communicate with devices on its local subnet (`192.168.1.0/24`) but cannot reach any hosts on external networks. Which of the following commands would most effectively diagnose if the default route is correctly configured?Troubleshooting
  49. 99.A team is adopting Infrastructure as Code (IaC) principles for their cloud environment. They want to manage their virtual machines, networks, and storage using code. Which of the following is a primary benefit of implementing IaC?Automation, Orchestration and Scripting
  50. 100.A system administrator wants to configure a container image to automatically run a specific command, `/usr/local/bin/start-app.sh`, every time a new container is launched from it, without requiring the user to specify the command manually during `docker run`. Which Dockerfile instruction should be used for this purpose?Services and User Management