XK0-005 Practice Test Questions

476 Questions


Following the migration from a disaster recovery site, a systems administrator wants a server to require a user to change credentials at initial login. Which of the following commands should be used to ensure the aging attribute?


A. chage -d 2 user


B. chage -d 0 user


C. chage -E 0 user


D. chage -d 1 user





B.
  chage -d 0 user

Summary:
After a disaster recovery migration, an administrator needs to force a user to change their password immediately upon first login. This is a common security practice to ensure the user sets a new, known password. In Linux, this is controlled by the password aging policy, specifically the "last password change date" field. Setting this date to a value that forces an immediate expiration accomplishes the goal.

Correct Option:

B. chage -d 0 user:
This is the correct command. The -d or --lastday option sets the number of days since January 1, 1970, that the password was last changed. Setting this value to 0 has a special meaning: it forces the password to be considered "expired," which will compel the user to change it immediately upon their next successful login.

Incorrect Options:

A. chage -d 2 user:
This command would set the last password change date to 2 days after the epoch (January 3, 1970). This is an arbitrary past date and does not guarantee that the password will be expired and require an immediate change upon login; it depends on the system's maximum password age policy.

C. chage -E 0 user:
The -E option sets the absolute date on which the user's account will be expired and disabled. Setting this to 0 (January 1, 1970) would lock the account immediately, preventing the user from logging in at all, which is not the desired outcome.

D. chage -d 1 user:
Similar to option A, this sets the last password change date to January 2, 1970. This is also an arbitrary past date and does not reliably trigger a forced password change at the next login like the special value 0 does.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 3.3: "Given a scenario, manage users and groups," which includes managing password aging policies for user accounts. The chage command and its -d 0 option are the standard tools for enforcing an immediate password change.

An administrator started a long-running process in the foreground that needs to continue without interruption. Which of the following keystrokes should the administrator use to continue running the process in the background?


A. bg


B. bg


C. jobs -1


D. bg &





A.
   bg

Summary:
The administrator has started a long-running process in the foreground and needs to move it to the background without interruption. This requires suspending the process temporarily and resuming it in the background. The correct keystroke sequence must first suspend the foreground process and then restart it as a background job, ensuring continuous operation.

Correct Option:

A. bg
suspends the foreground process, stopping it temporarily and returning control to the shell.

bg resumes the most recent suspended job in the background, allowing it to continue running without tying up the terminal.

This sequence is the standard method to background a running foreground process seamlessly.

Incorrect Option:

B. bg
ends the current shell session or signals EOF, terminating the process entirely rather than moving it to the background.

C. jobs -1
is not a valid shell keystroke for process control. jobs -1 lists jobs but does not suspend or background the process.

D. bg &
is the backspace key for editing, not process control. bg & is invalid syntax; bg alone backgrounds jobs, and & is used for starting new background processes.

Reference:

CompTIA XK0-005 exam objectives: https://www.comptia.org/certifications/linux

(Red Hat shell job control: https://access.redhat.com/documentation)

A DevOps engineer wants to allow the same Kubernetes container configurations to be deployed in development, testing, and production environments. A key requirement is that the containers should be configured so that developers do not have to statically configure custom, environment-specific locations. Which of the following should the engineer use to meet this requirement?


A. Custom scheduler


B. Node affinity


C. Overlay network


D. Ambassador container





D.
  Ambassador container

Summary:
The core requirement is to have a single, unchanging container configuration that can dynamically adapt to different environments (dev, test, prod) without static, hardcoded settings. This typically involves abstracting away environment-specific details like service endpoints, connection strings, or API URLs. The solution must act as an intermediary that handles this routing and configuration externally from the main application container.

Correct Option:

D. Ambassador container:
This is the correct pattern. An ambassador is a sidecar container that runs alongside the main application container in the same pod. It acts as a proxy, handling all communication to external services. The main application is configured to always talk to localhost (the ambassador), and the ambassador container itself is configured differently per environment (e.g., via ConfigMaps or environment variables) to know the actual endpoint for that specific environment (dev, test, prod). This allows the main application's configuration to remain static and portable.

Incorrect Options:

A. Custom scheduler:
A custom scheduler is responsible for deciding which node a pod should run on based on custom policies (e.g., based on GPU availability). It does not help with configuring environment-specific application settings or service discovery.

B. Node affinity:
Node affinity is a set of rules that constrains which nodes a pod is eligible to be scheduled on based on node labels (e.g., "run this pod only on nodes with the label environment=production"). It controls placement, not configuration.

C. Overlay network:
An overlay network is a virtual network that enables communication between pods across different nodes in a cluster. It solves networking connectivity problems but does not provide a mechanism for an application to dynamically discover different service endpoints based on its environment.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under the container management concepts in Objective 1.5. Understanding common container patterns, like the sidecar/ambassador pattern, is part of designing scalable and portable containerized applications. This pattern is documented in Kubernetes best practices for decoupling applications from their environment.

A systems administrator is tasked with configuring a repository on an RPM-based Linux system. Which of the following need to be reviewed and modified? (Select two).


A. /etc/yum.conf


B. /etc/apt/sources.list.d


C. /etc/pam.d


D. /etc/apt.conf


E. /etc/yum.repos.d


F. /etc/ssh/ssh_config





A.
  /etc/yum.conf

E.
  /etc/yum.repos.d

Summary:
This question involves configuring a repository on an RPM-based Linux system, which typically uses the Yellowdog Updater, Modified (YUM) or DNF package manager. The task requires identifying two configuration files that need review and modification to set up or adjust repositories, focusing on files relevant to RPM-based systems rather than Debian-based ones.

Correct Option:

A. /etc/yum.conf
The /etc/yum.conf file is the main configuration file for the YUM package manager on RPM-based systems, containing global settings like repository locations, caching, and debug levels.

Reviewing and modifying this file allows the administrator to adjust repository settings or add new ones, making it essential for repository configuration.

E. /etc/yum.repos.d
The /etc/yum.repos.d directory contains individual .repo files, each defining specific repositories with details like base URL, GPG keys, and enabled status.

Modifying or adding files here is a standard way to configure new repositories, requiring review to ensure proper setup on an RPM-based system.

Incorrect Option:

B. /etc/apt/sources.list.d
The /etc/apt/sources.list.d directory is used by Debian-based systems with the APT package manager to store additional repository lists.

This is irrelevant for an RPM-based system, making it an incorrect choice.

C. /etc/pam.d
The /etc/pam.d directory contains Pluggable Authentication Module (PAM) configuration files for user authentication, unrelated to repository management.

This has no bearing on configuring repositories, rendering it unsuitable.

D. /etc/apt.conf
The /etc/apt.conf file is used by Debian-based systems to configure APT settings, not applicable to RPM-based systems.

This is incorrect as it pertains to a different package management system.

F. /etc/ssh/ssh_config
The /etc/ssh/ssh_config file configures the SSH client, which is unrelated to repository management on any Linux system.

This is irrelevant to the task of configuring a repository.

Reference:
https://www.comptia.org/training/resources/exam-objectives (CompTIA Linux+ XK0-005 objectives)

A Linux administrator is investigating the reason a systemd timer is not running every night at midnight. The administrator sees the following unit file:
[Unit]
Description=Execute backup every day at midnight [Timer]
OnCalendar=--01 00:00:00 Unit=backup.service RandomizedDelaySec=10800 [Install]
WantedBy=multi-user.target
Which of the following modifications should the administrator make in the unit file? (Select two).


A. Remove RandomizedDelaySec=10800.


B. Add WakeSystem=Midnight.


C. Change OnCalendar to 00:00:00.


D. Add OnCalendar=--* daily.


E. Add AccuracySec=1.


F. Remove OnCalendar=--01 00:00:00.





A.
  Remove RandomizedDelaySec=10800.

C.
  Change OnCalendar to 00:00:00.

Summary:
The timer is configured to run on the first day of every month (--01) at midnight, not every day. Furthermore, it has a RandomizedDelaySec of 10,800 seconds (3 hours), meaning the service could run up to 3 hours after the scheduled time. To run every night at midnight, the calendar event must be changed to a daily schedule, and the random delay should likely be removed or significantly reduced to ensure it runs close to the intended time.

Correct Option:

A. Remove RandomizedDelaySec=10800.:
This is a necessary change. A 3-hour random delay means the backup could start as late as 3:00 AM, which may not be acceptable. For a critical nightly job that should run at midnight, this large delay should be removed.

C. Change OnCalendar to 00:00:00.:
This is the correct syntax for running daily at midnight. The current setting --01 00:00:00 means "the 1st day of the month at 00:00:00". Changing it to 00:00:00 means "daily at 00:00:00". Alternatively, daily is also a valid synonym.

Incorrect Options:

B. Add WakeSystem=Midnight.:
WakeSystem is used to wake the system from suspend if it's in a sleep state. Midnight is not a valid value; it would typically be a boolean (yes/no). This is not the core issue preventing the daily schedule.

*D. Add OnCalendar=-- daily.**:
This is redundant and incorrect syntax. --* is not a valid calendar event. The correct way to specify daily is simply daily or *-*-* 00:00:00.

E. Add AccuracySec=1.:
AccuracySec defines the accuracy of the timer. Setting it to 1 second might make the trigger more precise, but it does not fix the fundamental problem that the timer is only scheduled to run once a month, not daily.

F. Remove OnCalendar=--01 00:00:00.:
While this removes the incorrect monthly schedule, it does not add the correct daily schedule. The timer would have no schedule at all if this line is simply removed.

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 scheduling tasks using systemd timers. Understanding the OnCalendar syntax and the effect of RandomizedDelaySec is key to configuring timers correctly. The official systemd.timer and systemd.time man pages are the reference for the correct calendar format.

A Linux administrator is configuring a two-node cluster and needs to be able to connect the nodes to each other using SSH keys from the root account. Which of the following commands will accomplish this task?


A. [root@nodea ssh —i ~/ . ssh/±d rsa root@nodeb


B. [root@nodea scp -i . ssh/id rsa root@nodeb


C. [root@nodea ssh—copy-id —i .ssh/id rsa root@nodeb


D. [root@nodea # ssh add -c ~/ . ssh/id rsa root@nodeb


E. [root@nodea # ssh add -c ~/. ssh/id rsa root@nodeb





C.
  [root@nodea ssh—copy-id —i .ssh/id rsa root@nodeb

Summary:
The administrator needs to set up passwordless SSH authentication between two cluster nodes for the root account. This requires copying the public SSH key from one node (nodea) to the authorized_keys file on the other node (nodeb). The correct command must securely transfer the key and handle the remote file creation with the proper permissions.

Correct Option:

C. [root@nodea]# ssh-copy-id -i .ssh/id_rsa root@nodeb:
This is the standard and correct command for this task. The ssh-copy-id utility is specifically designed to install a public key on a remote server. The -i flag specifies the identity file (the public key) to copy. This command will copy the key from nodea to nodeb, placing it in /root/.ssh/authorized_keys and ensuring correct permissions.

Incorrect Options:

A. [root@nodea]# ssh -i ~/.ssh/id_rsa root@nodeb:
This command attempts to log into nodeb using a private key for authentication. It does not copy the key to the remote server; it only tests an existing key-based login configuration.

B. [root@nodea]# scp -i .ssh/id_rsa root@nodeb:
This command is incomplete and incorrect. The scp command requires both a source and a destination file. Even if complete, scp would just copy the key file to the remote server's home directory, not automatically append it to the authorized_keys file.

D. [root@nodea]# ssh-add -c ~/.ssh/id_rsa root@nodeb:
This command is syntactically incorrect. The ssh-add command is used to add private keys to the SSH authentication agent running on the local machine. It does not connect to a remote server or copy keys. The root@nodeb argument is invalid for this command.

E. [root@nodea]# ssh add -c ~/.ssh/id_rsa root@nodeb:
This command is invalid. There is no ssh add subcommand. The correct command for adding keys to the agent is ssh-add, but as explained in option D, this is not the tool for copying keys to a remote server.

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 systems administrator is adding a Linux-based server and removing a Windows-based server from a cloud-based environment. The changes need to be validated before they are applied to the cloud-based environment. Which of the following tools should be used to meet this requirement?


A. Ansible


B. git clone


C. git pull


D. terraform plan





D.
  terraform plan

Summary:
The administrator is making changes to the infrastructure definition (adding a Linux server, removing a Windows server) in a cloud environment. Before applying these changes, which could be costly or disruptive, they need to be validated. The requirement is for a tool that can show a preview or "dry run" of what will be created, modified, or destroyed in the cloud environment based on the new configuration, without actually making any changes.

Correct Option:

D. terraform plan:
This is the correct tool and command. Terraform is an Infrastructure as Code (IaC) tool used to define and provision cloud infrastructure. The terraform plan command is a critical step that creates an execution plan. It shows exactly what actions Terraform will take (e.g., "add," "remove," "change") when the configuration is applied, allowing the administrator to validate the changes safely before running terraform apply.

Incorrect Options:

A. Ansible:
Ansible is a configuration management and automation tool. It is used for configuring systems and deploying software on existing servers. While it has a --check (dry run) mode, it is not primarily designed for provisioning the underlying cloud servers themselves in the way Terraform is. Terraform's plan command is specifically built for this infrastructure validation purpose.

B. git clone:
This command is used to copy a Git repository from a remote source to a local machine. It is a version control operation and has no functionality for validating or planning cloud infrastructure changes.

C. git pull:
This command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Like git clone, it is a version control command and does not validate infrastructure configurations.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 4.1: "Given a scenario, implement and configure automation," which includes using Infrastructure as Code tools like Terraform. The ability to use terraform plan to preview changes is a fundamental and critical safety practice when managing cloud infrastructure.

A diagnostic tool reports a "host seems down" event for a server with an IP address of 192.168.47.44. Which of the following commands should the administrator use to confirm the host down event?


A. nmap 192.168.47.0/32


B. netcat 192.168.47.44


C. nmap 192.168.47.44 -Pn


D. ping -c 1 192.168.47.44





D.
  ping -c 1 192.168.47.44

Summary:
A diagnostic tool has reported that a specific host (192.168.47.44) seems to be down. The administrator needs a simple, direct method to test basic network reachability to that single host. The goal is to send a network request to the host and see if a reply is received, which confirms it is up and reachable at the network layer.

Correct Option:

D. ping -c 1 192.168.47.44:
This is the most straightforward command to confirm the host's status. The ping command uses ICMP Echo Request packets to test connectivity to a specified IP address. The -c 1 option sends exactly one packet. If the host is up and not blocking ICMP, it will reply. If the host is down or unreachable, the command will show a failure, confirming the "host seems down" event.

Incorrect Options:

A. nmap 192.168.47.0/32:
This command is syntactically incorrect and illogical. The /32 subnet mask specifies a single host (192.168.47.0 in this case), but nmap expects an IP range or network. More importantly, it's scanning the wrong IP address (192.168.47.0 is a network address, not the host 192.168.47.44).

B. netcat 192.168.47.44:
The netcat (or nc) command is used for reading from and writing to network connections. Without specifying a port, this command is incomplete and will fail. netcat is used to test if a specific TCP or UDP port is open, not for basic host reachability like ping.

C. nmap 192.168.47.44 -Pn:
The -Pn option in nmap tells it to skip the host discovery (ping) phase and treat the host as up, proceeding to scan all ports. This command would not confirm if the host is up; it would blindly attempt to scan ports on 192.168.47.44, which would be very slow if the host is actually down.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 4.1: "Given a scenario, analyze and troubleshoot network connectivity issues," which includes using tools to analyze and troubleshoot network resource issues. The ping command is the fundamental tool for testing basic IP connectivity to a remote host

The development team wants to prevent a file from being modified by all users in a Linux system, including the root account. Which of the following commands can be used to accomplish this objective?


A. chmod / app/conf/file


B. setenforce / app/ conf/ file


C. chattr +i /app/conf/file


D. chmod 0000 /app/conf/file





C.
  chattr +i /app/conf/file

Summary:
The requirement is to prevent all users, including the privileged root user, from modifying a specific file. Standard Linux file permissions can always be overridden by the root account, for example, by a root user running chmod to change the permissions. Therefore, a mechanism that operates at a lower level than the standard discretionary access control (DAC) is required to meet this objective.

Correct Option:

C. chattr +i /app/conf/file:
This command uses the chattr utility to set the "immutable" attribute on the file. When a file is marked immutable, the Linux kernel will prevent all write operations to it, including opening it for writing, renaming it, unlinking (deleting) it, and creating hard links to it. This restriction is enforced for all users, including root, making it the only command that fully meets the objective.

Incorrect Options:

A. chmod /app/conf/file:
This command is incomplete and invalid. The chmod command requires a mode (like 644 or a-w) to be specified. Even a correct command like chmod 000 /app/conf/file would only affect non-root users. The root account, due to its privileges, could simply change the permissions back to make the file writable.

B. setenforce /app/conf/file:
This command is incorrect and invalid. The setenforce command is used to change the global SELinux mode (e.g., setenforce 1 for Enforcing) and does not take a file path as an argument. It does not set attributes on individual files.

D. chmod 0000 /app/conf/file:
This command sets the file's standard permissions so that no user (owner, group, or other) has read, write, or execute access. However, the root user is not bound by these permissions and can still change them with chmod or override them using other methods, thus allowing root to modify the file.

Reference:
Linux man-pages project (chattr): The official documentation describes the file attributes that can be set, including the i flag for immutability.

An operations engineer is planning to start a container running a PostgreSQL database. The engineer wants the container to start automatically at system startup, mount the /home/db directory as /var/lib/postgresql inside the container, and expose port 5432 to the OS. Which of the following commands should the engineer run to achieve this task?


A. docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12


B. docker run -d --restart -p 5432:5432 --volume /var/lib/postgresql:/home/db postgresql:12


C. docker run -d --attach --platform 5432:5432 --volume /home/db:/var/lib/postgresql postgresql:12


D. docker run -d --init --restart --publish 5432:5432 --workdir /home/db:/var/lib/postgresql postgresql:12





A.
  docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12

Summary:
The engineer needs to start a PostgreSQL container with three specific requirements:

Start automatically at system startup (--restart always).

Mount the host directory /home/db to the container path /var/lib/postgresql (-v /host/path:/container/path).

Expose the container's port 5432 to the host OS (-p host_port:container_port).

The correct Docker command must use the appropriate flags to satisfy all these conditions simultaneously.

Correct Option:

A. docker run -d --restart always -p 5432:5432 -v /home/db:/var/lib/postgresql postgresql:12:
This is the correct command.

-d runs the container in detached (background) mode.

--restart always ensures the container restarts automatically if it stops, including after a system reboot.

-p 5432:5432 maps port 5432 on the host to port 5432 in the container.

-v /home/db:/var/lib/postgresql mounts the host directory /home/db to the container directory /var/lib/postgresql.

Incorrect Options:

B. docker run -d --restart -p 5432:5432 --volume /var/lib/postgresql:/home/db postgresql:12:
This command has two errors. First, the --restart flag requires a policy (e.g., always). Second, the volume mount is reversed (/var/lib/postgresql:/home/db). This would mount the container's data directory over the host's /home/db, which is incorrect and would hide the host's directory.

C. docker run -d --attach --platform 5432:5432 --volume /home/db:/var/lib/postgresql postgresql:12:
The --attach flag is used to attach local standard input, output, or error streams to the container, which contradicts the detached mode (-d). The --platform flag is for specifying the platform (e.g., linux/amd64), not for port mapping. The correct flag for port mapping is -p or --publish.

D. docker run -d --init --restart --publish 5432:5432 --workdir /home/db:/var/lib/postgresql postgresql:12:
The --init flag is used to run an init inside the container, which is unrelated. The --restart flag is missing its policy. The --workdir flag sets the working directory inside the container for the command to run; it is not used for volume mounting. The correct flag for mounting a volume is -v or --volume.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 1.5: "Given a scenario, manage and configure containers," which includes using Docker commands to run and manage containers with specific options for restart policies, port mapping, and volume mounting.

A Linux administrator wants to prevent the httpd web service from being started both manually and automatically on a server. Which of the following should the administrator use to accomplish this task?


A. systemctl mask httpd


B. systemctl disable httpd


C. systemctl stop httpd


D. systemctl reload httpd





A.
  systemctl mask httpd

Summary:
The requirement is to prevent the httpd service from being started under any circumstances, both manually by a user (systemctl start) and automatically at boot. Simply disabling a service prevents automatic start but does not block a manual start. The solution requires a command that places a more restrictive lock on the service.

Correct Option:

A. systemctl mask httpd:
This is the correct command. The mask operation creates a symbolic link from the service unit to /dev/null, making it impossible to start the service either manually or automatically. Any attempt to start it will fail with an error that the unit is "masked."

Incorrect Options:

B. systemctl disable httpd:
This command only removes the service from the list of units to be started automatically at boot. A user with the appropriate privileges can still start the service manually using systemctl start httpd.

C. systemctl stop httpd:
This command only stops the service if it is currently running. It does not prevent the service from being started again later, either manually or at the next boot.

D. systemctl reload httpd:
This command instructs a running service to reload its configuration files without a full restart. It has no effect on whether the service can be started.

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 systemd services. Understanding the critical difference between disable (prevents automatic start) and mask (prevents all starts) is a key skill.

A Linux administrator needs to remove all local firewall rules on a Linux system. Which of the following commands should the administrator run?


A. iptables -D


B. iptables -L


C. iptables -F


D. iptables -A





C.
  iptables -F

Summary:
The administrator needs to clear all existing firewall rules configured via iptables. This operation is often required to reset the firewall state or before applying a new set of rules. The command must target all chains (like INPUT, FORWARD, OUTPUT) and remove every rule within them, but it should not affect the default policy settings (e.g., DROP or ACCEPT).

Correct Option:

C. iptables -F:
The -F flag (or --flush) is the correct command for this task. It flushes or deletes all rules in the selected chain. If no specific chain is provided, it flushes all rules from all chains. This effectively removes all custom local firewall rules, leaving the chains empty but maintaining their default policies.

Incorrect Options:

A. iptables -D:
The -D flag (or --delete) is used to delete one specific rule from a chain. It requires the user to specify the chain and either the rule number or the exact rule specification, making it impractical for deleting all rules at once.

B. iptables -L:
The -L flag (or --list) is used to list all the rules in the selected chain. It is a read-only operation for displaying the current configuration and does not modify or remove any rules.

D. iptables -A:
The -A flag (or --append) is used to append a new rule to the end of a selected chain. This command is for adding rules, not removing them.

Reference:
Netfilter/iptables Project Documentation: The official man page details the various commands, explaining that -F is used to flush chains.


Page 17 out of 40 Pages
Previous