XK0-005 Practice Test Questions

476 Questions


A systems administrator is investigating why one of the servers has stopped connecting to the internet.

Which of the following is causing the issue?


A.

The DNS address has been commented out in the configuration file.


B.

The search entry in the /etc/resolv.conf file is incorrect.


C.

Wired connection 1 is offline.


D.

No default route is defined.





D.
  

No default route is defined.



Summary:
The server cannot connect to the internet. The ip route command output shows that there is no default route (also known as the default gateway) configured. A default route is essential for a system to communicate with networks outside of its immediate local subnet. Without it, the server has no path to send packets to the internet. The ping 8.8.8.8 failure confirms the lack of external network connectivity.

Correct Option:

D. No default route is defined:
This is the direct cause of the issue. The routing table only shows a route for the local 192.168.2.0/24 network. There is no default or 0.0.0.0/0 route pointing to a gateway that would handle traffic for all other destinations (like the internet).

Incorrect Options:

A. The DNS address has been commented out in the configuration file:
The ping command was using an IP address (8.8.8.8), not a hostname. Therefore, DNS is not involved in this test. A DNS issue would prevent name resolution but would not stop a ping to a direct IP address.

B. The search entry in the /etc/resolv.conf file is incorrect:
Similar to option A, this is a DNS configuration issue. The test used an IP address, so the search domain is irrelevant to the connectivity failure.

C. Wired connection 1 is offline:
The ip addr output shows that the ens160 interface is in the UP state and has a valid IP address (192.168.2.42/24), which means the wired connection is online and active at the link layer.

Reference:
Linux man-pages project (ip-route): The official documentation explains the routing table and the necessity of a default route for external communication.

A systems administrator pressed Ctrl+Z after starting a program using the command line, and the shell prompt was presented. In order to go back to the program, which of the following commands can the administrator use?


A.

fg


B.

su


C.

bg


D.

ed





A.
  

fg



Summary:
Pressing Ctrl+Z in a terminal sends a "suspend" signal (SIGTSTP) to the currently running foreground process. This stops the process and returns the user to the shell prompt, placing the stopped process in the background as a "job." To resume the process and bring it back to the foreground, where it regains control of the terminal, a specific job control command is used.

Correct Option:

A. fg:
This is the correct command. The fg (foreground) command brings the most recently suspended (or a specified) background job back into the foreground. This allows the program to continue running as if it had never been interrupted, with full control of the terminal for input and output.

Incorrect Options:

B. su:
The su (switch user) command is used to change the current user identity to another user, typically to gain root privileges. It has no function related to managing suspended processes or job control.

C. bg:
The bg (background) command is used to resume a suspended job, but it keeps the job running in the background. The job continues to execute, but it does not control the terminal, and the user gets the shell prompt back. This is the opposite of what the administrator wants, which is to return to the program.

D. ed:
The ed command is a very old, line-oriented text editor. It is a completely separate program and has no functionality for resuming suspended processes.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 3.1: "Given a scenario, use the appropriate system and service management commands to accomplish administrative tasks," which includes managing jobs and processes. Understanding job control commands like fg, bg, and jobs is a fundamental skill for command-line administration.

Based on an organization’s new cybersecurity policies, an administrator has been instructed to ensure that, by default, all new users and groups that are created fall within the specified values below.

To which of the following configuration files will the required changes need to be made?


A.

/etc/login.defs


B.

/etc/security/limits.conf


C.

/etc/default/useradd


D.

/etc/profile





A.
  

/etc/login.defs



Summary:
The requirement is to set organization-wide default values for new user and group IDs, ranges, and other related settings. This is a system-level configuration task that dictates the initial parameters assigned when a new user or group is created by commands like useradd and groupadd. The correct file is the central configuration file that these utilities reference for their default values.

Correct Option:

A. /etc/login.defs:
This is the primary configuration file for the shadow password suite. It is specifically designed to define system-wide defaults for range of user and group IDs (UID_MIN, UID_MAX, GID_MIN), password aging policies, mailbox location, and other settings related to user and group creation. Modifying this file ensures all new users and groups created by any administrator will inherit the specified values.

Incorrect Options:

B. /etc/security/limits.conf:
This file is used to set limits on system resources (such as the number of processes, maximum file size, or CPU time) that can be allocated for a user or group. It does not control the default UID/GID ranges assigned during account creation.

C. /etc/default/useradd:
This file contains default values specifically for the useradd command, such as the default home directory skeleton, default shell, and expiration date. While important, its scope is narrower than /etc/login.defs and it does not control the default UID/GID ranges or group creation defaults.

D. /etc/profile:
This is a global shell script executed at login for all users running the Bash shell. It is used to set environment variables (like PATH) and startup behaviors for user sessions. It has no control over the UID or GID values assigned when a new user or group is created.

Reference:
Linux man-pages project (login.defs): The official documentation details the purpose of the file and all configurable options, including UID_MIN, GID_MIN, and others.

A Linux administrator needs to obtain a list of all volumes that are part of a volume group. Which of the following commands should the administrator use to accomplish this task?


A.

vgs


B.

lvs


C.

fdisk -1


D.

pvs





B.
  

lvs



Summary:
The administrator needs to list the volumes within a volume group. In LVM terminology, a "volume" that is usable as a filesystem is called a Logical Volume. These are created from the pool of space (the Physical Extents) that is provided by the Physical Volumes within a Volume Group. The command must specifically query and display information about these logical volumes.

Correct Option:

B. lvs:
This is the correct command. The lvs (logical volume display) command provides a formatted report of all logical volumes in the system. It shows details such as the LV name, the volume group it belongs to, its size, and its layout. This directly answers the question of listing all volumes that are part of a volume group.

Incorrect Options:

A. vgs:
The vgs (volume group display) command provides a formatted report about the volume groups themselves, such as their name, total size, free space, and the number of physical and logical volumes they contain. It does not list the individual logical volumes within those groups.

C. fdisk -l:
The fdisk -l command lists the partitions on block devices (like /dev/sda). It operates at the disk partitioning level, which is a layer below LVM. It will show the partitions that are used as physical volumes, but it cannot see the logical volumes that LVM creates on top of them.

D. pvs:
The pvs (physical volume display) command provides a formatted report about the physical volumes. These are the underlying disks or partitions that provide the raw storage to volume groups. It does not show the logical volumes that are created from the pooled space.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 3.2: "Given a scenario, manage storage, files, and directories in a Linux environment," which includes configuring and managing logical volume manager (LVM) storage. Knowing the distinction between pvs, vgs, and lvs is essential for working with LVM.

Which of the following commands is used to configure the default permissions for new files?


A.

setenforce


B.

sudo


C.

umask


D.

chmod





C.
  

umask



Summary:
The question asks for the command that sets the default permissions for newly created files and directories. This is not about changing permissions on existing files but about defining the base permissions that are applied when a file or directory is first created by a user or process. The correct command controls a kernel variable that subtracts permission bits from the maximum default permissions.

Correct Option:

C. umask:
This is the correct command. The umask (user file-creation mask) is a value that the system subtracts from the base permissions (typically 666 for files and 777 for directories) to determine the default permissions for new items. For example, a common umask of 022 results in default permissions of 644 for files and 755 for directories.

Incorrect Options:

A. setenforce:
This command is used to change the mode of SELinux (Security-Enhanced Linux) between Enforcing and Permissive. It is a mandatory access control system and does not manage standard file creation permissions.

B. sudo:
This command allows a permitted user to execute a command as the superuser or another user. It is a privilege escalation tool, not a permission configuration command.

D. chmod:
This command is used to change the access permissions of existing files and directories. It does not configure the default permissions applied to new files.

Reference:
Bash Reference Manual (Bourne Shell Builtins): The official documentation describes umask as a builtin command that sets the file creation mask.

A systems administrator is investigating an issue in which one of the servers is not booting up properly. The journalctl entries show the following:

Which of the following will allow the administrator to boot the Linux system to normal mode quickly?


A.

Comment out the /opt/app filesystem in /etc/fstab and reboot.


B.

Reformat the /opt/app filesystem and reboot.


C.

Perform filesystem checks on local filesystems and reboot.


D.

Trigger a filesystem relabel and reboot.





A.
  

Comment out the /opt/app filesystem in /etc/fstab and reboot.



Summary:
The system is failing to boot because it cannot mount the /opt/app filesystem, as indicated by the journalctl entry "Failed to mount /opt/app." This failure prevents the boot process from completing successfully, forcing the system into emergency mode. The fastest way to regain access is to temporarily remove the problematic entry from the boot-time mount configuration.

Correct Option:

A. Comment out the /opt/app filesystem in /etc/fstab and reboot.:
This is the quickest and most direct solution. The /etc/fstab file defines which filesystems are mounted at boot. By commenting out the line for /opt/app (adding a # at the beginning), the system will skip the attempt to mount this filesystem during the next boot. This will allow the system to proceed to a normal, multi-user mode. The administrator can then log in and diagnose the underlying issue with the /opt/app device or filesystem without being locked out.

Incorrect Options:

B. Reformat the /opt/app filesystem and reboot.:
This is a destructive and premature action. The error does not specify the cause; it could be a misconfigured device path in /etc/fstab, a failed disk, or a corrupted filesystem. Reformatting would erase all data on that filesystem and should only be a last resort after data recovery attempts.

C. Perform filesystem checks on local filesystems and reboot.:
While a filesystem check might be necessary, the command fsck typically runs automatically on reboot if a filesystem is marked as dirty. The system is already failing before this check can complete or bypass the mount failure. The immediate problem is the mount dependency, not necessarily the check itself.

D. Trigger a filesystem relabel and reboot.:
A filesystem relabel is specific to SELinux, which manages security contexts. This action would not resolve a fundamental failure to mount a filesystem, which is likely due to a hardware, device, or configuration error in /etc/fstab.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 1.3: "Given a scenario, conduct a Linux boot process and troubleshooting," which includes troubleshooting boot issues and managing the fstab file. Knowing that commenting out a problematic line in /etc/fstab is the standard first step to recover from a boot failure due to a missing mount is a critical skill.

A systems administrator wants to be sure the sudo rules just added to /etc/sudoers are valid. Which of the following commands can be used for this task?


A.

visudo -c


B.

test -f /etc/sudoers


C.

sudo vi check


D.

cat /etc/sudoers | tee test





A.
  

visudo -c



Summary:
The administrator needs to validate the syntax of the /etc/sudoers file after making changes. The sudoers file has a specific grammar, and a syntax error can lock users out of using sudo entirely. The correct command must perform a dedicated syntax check on the sudoers file to ensure all rules are correctly formatted before the configuration is applied.

Correct Option:

A. visudo -c:
This is the standard and correct command for this task. The visudo utility is the safe way to edit the sudoers file, and the -c (check) flag instructs it to perform a syntax check on the file. It will report any errors found, allowing the administrator to fix them before they cause problems.

Incorrect Options:

B. test -f /etc/sudoers:
This command only checks if /etc/sudoers is a regular file that exists. It does not validate the contents or syntax of the file.

C. sudo vi check:
This command would try to open a file named check for editing with vi, using sudo for privileges. It has no relation to validating the sudoers file syntax.

D. cat /etc/sudoers | tee test:
This command would simply display the contents of the sudoers file and write a copy to a file named test. It performs no syntax validation.

Reference:
Linux man-pages project (visudo): The official documentation explains that visudo -c checks the sudoers file for syntax errors.

A Linux administrator found many containers in an exited state. Which of the following commands will allow the administrator to clean up the containers in an exited state?


A.

docker rm --all


B.

docker rm $(docker ps -aq)


C.

docker images prune *


D.

docker rm --state exited





B.
  

docker rm $(docker ps -aq)



Summary:
The administrator needs to remove Docker containers that are in an "exited" state. This requires a command that can first list all containers with their status and then remove only those that have exited. The correct command must filter for containers based on their state and then perform a cleanup operation.

Correct Option:

B. docker rm $(docker ps -aq):
This is the correct and most common command for this task.

docker ps -aq lists all containers (-a), including stopped ones, and only shows their IDs (-q).

$(...) is command substitution, which passes the list of container IDs to the docker rm command.

docker rm removes the specified containers. While this removes all containers (running and stopped), it effectively cleans up the exited ones. For a more precise command targeting only exited containers, docker rm $(docker ps -aq -f status=exited) would be used, but among the given options, B is the standard cleanup command.

Incorrect Options:

A. docker rm --all:
There is no --all flag for the docker rm command. The correct flag to remove all containers is docker rm -f $(docker ps -aq) or using the prune command.

C. docker images prune *:
The docker images command manages images, not containers. The correct command for pruning unused images is docker image prune. The * is invalid syntax and this command does not address containers.

D. docker rm --state exited:
The docker rm command does not have a --state filter. Filters are applied using the docker ps command to generate the list of containers to remove.

Reference:
Docker Documentation (docker rm): The official documentation for the docker rm command.

In which of the following filesystems are system logs commonly stored?


A.

/var


B.

/tmp


C.

/etc


D.

/opt





A.
  

/var



Summary:
System and application logs are dynamic data that grow over time, containing information such as kernel messages, service errors, authentication attempts, and general system events. The Linux Filesystem Hierarchy Standard (FHS) defines a specific directory for these variable, changing files to keep them separate from static configuration files, temporary files, and user programs.

Correct Option:

A. /var:
This is the correct directory. The name var stands for "variable." This filesystem is designated for files whose content is expected to continually change during the operation of the system. The /var/log subdirectory is the standard location where most system logs (from journald, syslog, and individual applications like Apache or MySQL) are stored.

Incorrect Options:

B. /tmp:
This directory is for temporary files created by users and applications. These files are often deleted upon system reboot and are not intended for persistent, important system data like logs.

C. /etc:
This directory contains static, editable configuration files for the system and applications. While configuration might dictate how logging works, the actual log files themselves are not stored here.

D. /opt:
This directory is used for installing optional add-on application software packages (like third-party or proprietary applications). The applications themselves reside here, but their runtime logs are typically still written to /var/log.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This knowledge is foundational and supports several objectives, particularly Objective 4.3: "Given a scenario, analyze and troubleshoot application and hardware issues," which involves using system logs for troubleshooting. The Linux Filesystem Hierarchy Standard (FHS) defines /var as the location for variable data like logs.

A Linux system is failing to boot with the following error:

Which of the following actions will resolve this issue? (Choose two.)


A.

Execute grub-install --root-directory=/mnt and reboot.


B.

Execute grub-install /dev/sdX and reboot.


C.

Interrupt the boot process in the GRUB menu and add rescue to the kernel line.


D.

Fix the partition modifying /etc/default/grub and reboot.


E.

Interrupt the boot process in the GRUB menu and add single to the kernel line.


F.

Boot the system on a LiveCD/ISO.





B.
  

Execute grub-install /dev/sdX and reboot.



F.
  

Boot the system on a LiveCD/ISO.



Summary:
The error file '/boot/grub2/i386-pc/normal.mod' not found indicates that the GRUB bootloader's core modules are missing or corrupted. This is a severe boot issue where the system cannot proceed past the initial bootloader stage. The GRUB configuration needs to be reinstalled to the disk's master boot record (MBR) or GPT BIOS boot partition. This typically requires booting from an external source to access and repair the main system.

Correct Options:

B. Execute grub-install /dev/sdX and reboot:
This is the core corrective action. Once the system is booted from a rescue medium, the administrator must chroot into the broken system and run grub-install on the main boot disk (e.g., /dev/sda) to reinstall the GRUB bootloader and its modules, restoring the missing normal.mod file and other components.

F. Boot the system on a LiveCD/ISO:
This is the necessary first step. Since the main system cannot boot, an external bootable medium (Live CD/USB) is required to gain access to the system's root filesystem, diagnose the problem, and perform the repair operations like grub-install.

Incorrect Options:

A. Execute grub-install --root-directory=/mnt and reboot:
The --root-directory option is largely deprecated. The standard method is to use chroot to make the rescued system's root the actual root, then run grub-install /dev/sdX without this flag.

C. Interrupt the boot process in the GRUB menu and add rescue to the kernel line:
rescue is not a standard kernel parameter for fixing this level of GRUB corruption. The boot fails before the kernel is even loaded, so this intervention point is not available.

D. Fix the partition modifying /etc/default/grub and reboot:
The file /etc/default/grub controls GRUB's menu configuration, not the core bootloader binaries and modules. The error is about missing files, not an incorrect configuration. Furthermore, the system cannot boot to apply these changes.

E. Interrupt the boot process in the GRUB menu and add single to the kernel line:
The single parameter boots the system into single-user mode. Like option C, this requires the kernel to be loaded, which happens after the stage where the current error occurs. The GRUB failure prevents this.

Reference:
GNU GRUB Manual (grub-install): The official documentation details the use of grub-install for installing the bootloader on a device.

A user generated a pair of private-public keys on a workstation. Which of the following commands will allow the user to upload the public key to a remote server and enable passwordless login?


A.

scp ~/.ssh/id_rsa user@server:~/


B.

rsync ~ /.ssh/ user@server:~/


C.

ssh-add user server


D.

ssh-copy-id user@server





D.
  

ssh-copy-id user@server



Summary:
The user needs to transfer the public key to a remote server and place it in the correct file with the correct permissions to enable passwordless SSH login. This involves copying the ~/.ssh/id_rsa.pub (or similar) file to the remote server and appending it to the ~/.ssh/authorized_keys file in the user's home directory. The process must also ensure the remote .ssh directory and authorized_keys file have secure permissions.

Correct Option:

D. ssh-copy-id user@server:
This is the dedicated, safe, and correct command for this task. It automatically copies the default public key (~/.ssh/id_rsa.pub) to the specified server and user account. It handles creating the ~/.ssh directory and the authorized_keys file on the remote server with the proper permissions (700 for the directory and 600 for the file), eliminating manual steps and potential errors.

Incorrect Options:

A. scp ~/.ssh/id_rsa user@server:~/:
This command copies the private key (id_rsa) to the remote server. The private key should never be shared or transmitted. It must remain secure on the local workstation. This action is a severe security mistake.

B. rsync ~/.ssh/ user@server:~/:
This command would attempt to sync the entire local ~/.ssh directory, including the private key, to the remote server's home directory. This is incorrect and insecure for the same reason as option A. It also does not correctly place the public key into the authorized_keys file.

C. ssh-add user server:
The ssh-add command is used to add private keys to the SSH authentication agent, which manages keys for convenience (so you don't have to type the passphrase repeatedly). It does not copy keys to remote servers.

Reference:
OpenSSH Manual (ssh-copy-id): The official documentation explains that ssh-copy-id is used to install your public key in a remote machine's authorized_keys.

A Linux administrator has set up a new DNS forwarder and is configuring all internal servers to use the new forwarder to look up external DNS requests. The administrator needs to modify the firewall on the server for the DNS forwarder to allow the internal servers to communicate to it and make the changes persistent between server reboots. Which of the following commands should be run on the DNS forwarder server to accomplish this task?


A.

ufw allow out dns


B.

systemctl reload firewalld


C.

iptables -A OUTPUT -p udp -ra udp -dport 53 -j ACCEPT


D.

flrewall-cmd --zone-public --add-port-53/udp --permanent





D.
  

flrewall-cmd --zone-public --add-port-53/udp --permanent



Summary:
A DNS forwarder needs to accept incoming queries from internal servers on the standard DNS port (UDP 53). The requirement is to modify the firewall to allow this traffic and, critically, to make the change persistent across reboots. The solution must use a command that both opens the correct port and saves the rule to the permanent configuration.

Correct Option:

D. firewall-cmd --zone=public --add-port=53/udp --permanent:
This is the correct command. It uses firewalld, the default dynamic firewall manager on many modern Linux distributions. The --add-port=53/udp specifically opens port 53 for UDP traffic, which is the standard for DNS queries. The --permanent flag is crucial as it writes the rule to the configuration file, ensuring it persists after a reboot. The rule is applied to the public zone, which is commonly used for server interfaces.

Incorrect Options:

A. ufw allow out dns:
This command is incorrect for two main reasons. First, it uses ufw (Uncomplicated Firewall), which is common on Ubuntu but not the standard tool referenced in the exam objectives. Second and more importantly, it creates an outbound rule (allow out), but the requirement is to allow inbound connections to the DNS forwarder from other servers.

B. systemctl reload firewalld:
This command only reloads the firewalld service to apply existing permanent rules; it does not create or add any new firewall rules itself. It is a step that would be taken after running the correct command (Option D) to apply the change, but it does not accomplish the primary task of opening the port.

C. iptables -A OUTPUT -p udp --dport 53 -j ACCEPT:
This command uses the lower-level iptables tool to add a rule. However, like option A, it is an output rule (-A OUTPUT), which is for outbound traffic. Furthermore, an iptables rule added this way is not persistent by default and would be lost after a reboot unless saved with a separate utility like iptables-save.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This question aligns with Objective 4.2: "Given a scenario, implement and configure Linux firewalls and access control options." The firewall-cmd utility is the primary tool listed for managing firewalld, and the --permanent flag is a key concept for making runtime changes persistent.


Page 6 out of 40 Pages
Previous