CompTIA Linux+ (XK0-006) practice questions
208 free questions with answers and explanations.
- 151.A technician runs `free -h` on a server that appears sluggish: total used free shared buff/cache available Mem: 15Gi 2.1Gi 1.2Gi 200Mi 12Gi 13Gi Which column should the technician check to determine how much memory is actually available for new applications?Troubleshooting
- 152.A technician needs to encrypt a new partition /dev/sdb1 using LUKS before creating a filesystem on it. Which sequence of commands correctly encrypts the partition, opens it for use, and creates an ext4 filesystem on the mapped device?System Management
- 153.A system administrator is setting up a shared directory, `/data/projects`, where multiple users from the `devteam` group will collaborate. All new files and subdirectories created within `/data/projects` by any `devteam` member should automatically inherit the `devteam` group ownership. The directory also needs to be writable by `devteam` members and readable by others, but not writable by others. Which `chmod` command should be applied to `/data/projects`?Services and User Management
- 154.A technician needs to verify which services on a server are actively listening for incoming TCP and UDP connections, showing port numbers without resolving hostnames. Which command accomplishes this?Troubleshooting
- 155.A network technician needs to quickly determine which processes are listening on TCP and UDP ports on a Linux server, along with the associated process IDs. Which command provides this information?System Management
- 156.According to the Filesystem Hierarchy Standard (FHS), which directory contains host-specific system configuration files, including /etc/passwd and /etc/fstab?System Management
- 157.A technician must encrypt an entire new data partition, /dev/sdb1, using LUKS full-disk encryption, then mount it for use with a mapped device name of secure_vol. Which sequence of commands is correct?Security
- 158.A team is designing a new application and needs to define its infrastructure components (virtual machines, networks, storage) in a declarative way, ensuring consistency across different environments and enabling version control of the infrastructure itself. They want to use a tool that treats infrastructure definitions as code. Which concept are they primarily adopting?Automation, Orchestration and Scripting
- 159.A system administrator needs to check the boot order and active boot entry for a UEFI-based Linux server. Which command should be used?System Management
- 160.A developer is working on a Linux system and wants to ensure that a specific Python script, `/opt/scripts/data_processor.py`, executes with the permissions of the `datauser` group, even when run by other users. The script itself should not be writable by anyone other than its owner. Which `chmod` command should be used?Services and User Management
- 161.A system administrator is investigating intermittent application timeouts on a server. They suspect that DNS resolution might be slow or failing. To test DNS resolution for a specific domain (`example.com`) using a particular DNS server (`192.168.1.1`), which command provides the most direct and specific test?Troubleshooting
- 162.A technician needs to ensure that a newly modified `systemd` service unit file, `/etc/systemd/system/myservice.service`, is reloaded by the `systemd` daemon without restarting the entire system. Which command should the technician execute?Services and User Management
- 163.A system administrator is troubleshooting a service that fails to start at boot. The service unit file, `mydaemon.service`, contains `Requires=network-online.target`. Which of the following commands would help verify if the `network-online.target` is being reached or if there are issues preventing it from being achieved?Services and User Management
- 164.A technician manually downloaded a .deb package and installed it with 'dpkg -i package.deb', but the installation failed due to unmet dependencies. Which command should be run next to automatically resolve and install the missing dependencies?System Management
- 165.An administrator runs `iostat -x 2` and observes the following for /dev/sda: r/s: 120 w/s: 340 await: 85.00 %util: 98.50 What does the %util value indicate about this disk?Troubleshooting
- 166.A storage administrator checks a two-disk RAID 1 array and sees the following output from 'mdadm --detail /dev/md0': 'State: clean, degraded' and one device listed as 'removed'. After replacing the failed physical disk and creating a new partition /dev/sdc1, which command correctly restores full redundancy to the array?System Management
- 167.A software team is implementing a CI/CD pipeline. They want to ensure that every code change undergoes automated testing, code quality checks, and then, if successful, is automatically deployed to a staging environment. If any of these steps fail, the pipeline should stop, and the relevant team members should be notified. Which CI/CD principle does this scenario primarily illustrate?Automation, Orchestration and Scripting
- 168.A system administrator is investigating a network performance issue where connections to an external server are occasionally timing out. The local server's network configuration appears correct, and local network pings are successful. The administrator wants to identify where packets are being dropped or delayed along the route to the external server. Which command would be most effective for this task?Troubleshooting
- 169.A technician installs a new logging service package on a Rocky Linux server. The service should automatically start every time the server boots, but the technician does not want it to start immediately during the current session. Which command should the technician run?System Management
- 170.A security analyst is writing a Python script to parse system logs. The script needs to extract specific error codes that follow a pattern like `ERROR-[A-Z]{3}-[0-9]{4}` from each line. Which Python module is best suited for this task?Automation, Orchestration and Scripting
- 171.A technician is using the interactive fdisk utility on /dev/sdb to prepare a new physical volume for LVM. After creating the partition with 'n', which fdisk command is used to change the partition's system ID to 'Linux LVM' (8e) before writing the changes?System Management
- 172.A client reports that a web application running on a Linux server is inaccessible, and they receive 'Connection refused' errors. The technician checks the web server service status, which shows it is running, but `ss -tlnp` does not list the web server's expected listening port. What is the most likely cause?Troubleshooting
- 173.A system administrator observes that a Linux server's CPU utilization is consistently high, and `top` shows a significant percentage of CPU time spent in 'si' (software interrupts). What is the most likely cause for this behavior?Troubleshooting
- 174.A system administrator is troubleshooting a server experiencing slow disk I/O. They run `iostat -x 2` and observe the following output for `/dev/sdb`:Troubleshooting
- 175.A system administrator is troubleshooting a server that is unable to resolve external hostnames. Internal hostnames resolve correctly. A `dig www.example.com` command from the server returns `connection timed out; no servers could be reached`. Which of the following is the most likely issue?Troubleshooting
- 176.A technician is investigating a Linux server that fails to boot, displaying a `kernel panic` message related to a missing root filesystem. The server recently had its root filesystem moved from `/dev/sda1` to `/dev/sdb1`. Which file is most likely misconfigured, preventing the system from finding the new root filesystem?Troubleshooting
- 177.A technician is troubleshooting a Linux server that has recently become unresponsive. They suspect a process might be consuming excessive resources. Which of the following commands would best identify processes consuming the most CPU and memory in real-time?Troubleshooting
- 178.A system administrator is investigating a Linux server that intermittently loses network connectivity. Pinging local hosts works, but external websites are unreachable. The administrator suspects a problem with the default gateway. Which command should they use to check the current routing table, specifically looking for the default route?Troubleshooting
- 179.A technician is troubleshooting a Linux server where a critical service, `myapp.service`, fails to start correctly. The `systemctl status myapp.service` command shows `Active: failed (Result: exit-code)`. Further investigation with `journalctl -xeu myapp.service` reveals an error message: `ExecStart=/usr/local/bin/myapp: No such file or directory`. What is the most probable cause of this service failure?Troubleshooting
- 180.A system administrator needs to ensure that all users on a Linux server are subject to a maximum of 3 failed login attempts before their account is locked out for 5 minutes. Which PAM configuration file should be modified to implement this policy for local user authentication?Security
- 181.A system administrator needs to remove a user account named `olduser` from a Linux system, including their home directory and mail spool. Which of the following commands will accomplish this task safely and completely?Services and User Management
- 182.A system administrator is analyzing the default permissions for newly created files on a Linux system. A new file `newfile.txt` is created by a user with a `umask` value of `0027`. What will be the octal permissions of `newfile.txt`?Services and User Management
- 183.A system administrator is debugging a custom `systemd` service unit named `mywebapp.service` that fails to start correctly. The administrator suspects an issue with the environment variables or command execution path. Which `journalctl` command would be most effective for viewing detailed logs specifically related to this service, including any output to standard error?Services and User Management
- 184.A system administrator is writing a Bash script to iterate through a list of usernames stored in a file named `users.txt`, one username per line. For each username, the script needs to perform a specific action. Which of the following Bash constructs is most appropriate for reading each line from `users.txt` and processing it?Automation, Orchestration and Scripting
- 185.A system administrator needs to schedule a script, `/usr/local/bin/backup.sh`, to run daily at 3:00 AM. Which of the following commands would correctly add this entry to the root user's crontab?Services and User Management
- 186.A security auditor needs to verify the integrity of the 'passwd' database on a Linux system by comparing its current state against a previously established baseline. Which command, along with its appropriate options, would most effectively perform this check using AIDE?Security
- 187.A system administrator is preparing to deploy a new Docker container that needs to run a custom Python script as its primary process. The script `app.py` is located in the container's `/app` directory. Which `Dockerfile` instruction should be used to ensure this script is executed when the container starts, allowing arguments to be easily passed to `app.py`?Services and User Management
- 188.A system administrator is deploying a containerized application that requires persistent storage for its database. The database files should be stored in a host directory `/var/lib/myapp/db` to ensure data survives container recreation and can be easily backed up. The container's internal database path is `/data/db`. Which `docker run` command option correctly configures this persistent storage?Services and User Management
- 189.A system administrator is auditing the `/etc/passwd` file and notices an entry for a user `legacyuser` with `::/bin/false` as the shell. What does this configuration indicate regarding `legacyuser`'s login capabilities?Services and User Management
- 190.A system administrator needs to grant the `webdevs` group read, write, and execute permissions to a specific directory `/var/www/html/projectA`, while ensuring that all files and subdirectories created within `projectA` by any member of `webdevs` automatically inherit the `webdevs` group ownership. Which two commands, executed consecutively, will achieve this?Services and User Management
- 191.A junior administrator is trying to remove the `devops` group from a Linux system. They attempt to use `groupdel devops` but receive an error indicating the group is still the primary group for one or more users. Which of the following is the correct sequence of actions to safely remove the `devops` group?Services and User Management
- 192.A system administrator needs to create a new `systemd` target named `app-maintenance.target` that should be reached after the `multi-user.target` but before any graphical desktop environment. This target should depend on a custom service `app-setup.service` to ensure it runs before any maintenance scripts. Which `systemd` unit file configuration snippet is most appropriate for `app-maintenance.target`?Services and User Management
- 193.A system administrator is configuring a new Linux server and needs to enable a `systemd` timer unit named `mybackup.timer` to ensure that a corresponding service `mybackup.service` runs periodically. After creating both unit files, which command should the administrator use to make sure the timer starts automatically at boot and becomes active immediately?Services and User Management
- 194.A system administrator is using Ansible to manage a fleet of Linux servers. They need to ensure that a specific package, `nginx`, is installed and running, and that its service is enabled to start upon system boot. Which Ansible module and associated tasks would correctly achieve this goal?Automation, Orchestration and Scripting
- 195.A developer is creating a Python script that needs to interact with the operating system to list the contents of a directory. They want to execute the `ls -l` command and capture its standard output. Which `subprocess` module function is the most appropriate and recommended way to achieve this, while also handling potential errors?Automation, Orchestration and Scripting
- 196.A system administrator needs to manage a user's password policy. Specifically, they want to enforce that the `appuser` password expires after 90 days, and the user receives a warning 7 days before expiration. Which of the following commands correctly configures these settings?Services and User Management
- 197.A system administrator is auditing the `/etc/group` file and encounters an entry for `developers:x:1001:jane,john`. What does the `x` field signify in this entry?Services and User Management
- 198.A junior administrator is configuring a new Linux server and needs to enable kernel-level packet filtering with nftables. After installing the 'nftables' package, which command would be used to create a basic 'filter' table with an 'input' chain that drops all incoming traffic by default?Security
- 199.A system administrator is writing a Bash script that needs to create a directory `/var/log/myapp` if it does not already exist. They also want to ensure that the script exits immediately if the directory creation fails due to permissions or any other error. Which Bash command or construct would best achieve this?Automation, Orchestration and Scripting
- 200.A system administrator needs to create a new user `reports` on a Linux system. This user should have a home directory at `/srv/reports`, a primary group `dataanalysts`, and a login shell of `/bin/bash`. The home directory should not be created automatically, as it already exists and contains pre-existing data. Which of the following commands will accomplish this?Services and User Management