XK0-005 Practice Test Questions

476 Questions


A Linux administrator needs to ensure that Java 7 and Java 8 are both locally available for developers to use when deploying containers. Currently only Java 8 is available. Which of the following commands should the administrator run to ensure both versions are available?


A.

docker image load java:7


B.

docker image pull java:7


C.

docker image import java:7


D.

docker image build java:7





B.
  

docker image pull java:7



Summary:
The administrator needs to make the Java 7 container image available locally on the machine so developers can use it. Container images are typically stored in a central registry, such as Docker Hub. The correct command must download (or "pull") the specified image from the registry to the local machine's image cache, making it available for creating containers.

Correct Option:

B. docker image pull java:7:
This is the standard and correct command. It contacts the configured container registry (by default, Docker Hub) and downloads the image tagged as java:7 to the local system. After this command completes, both java:8 and java:7 will be available for use with docker run or in container deployments.

Incorrect Options:

A. docker image load java:7:
The load command is used to import an image from a tar archive that was previously created with docker save. It is used for loading images from a file, not from a registry. Since the image is on a registry, pull is the correct operation.

C. docker image import java:7:
The import command creates a filesystem image from a tarball (often a root filesystem). It is not used for downloading pre-built application images like Java from a registry.

D. docker image build java:7:
The build command creates an image from a Dockerfile. It is used for creating custom images from source code and instructions, not for downloading existing, pre-built images from a registry.

Reference:
Docker Documentation (docker pull): The official documentation explains that docker pull downloads an image from a registry.

Which of the following files holds the system configuration for journal when running systemd?


A.

/etc/systemd/journald.conf


B.

/etc/systemd/systemd-journalctl.conf


C.

/usr/lib/systemd/journalctl.conf


D.

/etc/systemd/systemd-journald.conf





A.
  

/etc/systemd/journald.conf



Summary:
The question asks for the configuration file that controls the behavior of the systemd-journald service. This service is responsible for collecting and storing log data (journal logs) on systems using systemd. Like other core systemd components, it has a dedicated configuration file where settings like log storage location, size limits, and forwarding rules can be defined.

Correct Option:

A. /etc/systemd/journald.conf:
This is the correct and standard location for the system-wide configuration of the systemd-journald service. Administrators edit this file to set parameters like Storage=, SystemMaxUse=, and ForwardToSyslog= to control how journal logs are handled.

Incorrect Options:

B. /etc/systemd/systemd-journalctl.conf:
This file name is incorrect and does not exist. journalctl is the command-line tool for querying the logs, not the service that collects them. The service is named systemd-journald.

C. /usr/lib/systemd/journalctl.conf:
This path is also incorrect. The /usr/lib/systemd/ directory is typically reserved for default unit files and configuration provided by the distribution packages. The administrator should not edit files here; the active configuration is in /etc/.

D. /etc/systemd/systemd-journald.conf:
This is a commonly chosen distractor due to the accurate service name. However, the official and standard configuration file is named journald.conf, not systemd-journald.conf.

Reference:
systemd Official Documentation (journald.conf): The official man page details all the configuration options available in the journald.conf file.

A Linux administrator is providing a new Nginx image from the registry to local cache. Which of the following commands would allow this to happen?


A.

docker pull nginx


B.

docker attach nginx


C.

docker commit nginx


D.

docker import nginx





A.
  

docker pull nginx



Summary:
The task is to transfer a new Nginx image from a remote registry (like Docker Hub) to the server's local cache. The local cache is the storage on the Docker host where downloaded container images are kept. The command must be one that fetches an image from a registry and stores it locally so it is ready to be used for creating containers.

Correct Option:

A. docker pull nginx:
This is the correct command. The docker pull command contacts the configured container registry (Docker Hub by default) and downloads the specified image (nginx) and all its layers to the local Docker host's cache. Once pulled, the image can be used to run containers without needing to download it again.

Incorrect Options:

B. docker attach nginx:
This command is used to connect your terminal's standard input, output, and error (or a combination of the three) to a running container. It is used for interacting with an already running container, not for downloading images.

C. docker commit nginx:
This command is used to create a new image from a container's changes. The syntax is docker commit [CONTAINER] [NEW_IMAGE_NAME]. It does not download an image from a registry; instead, it saves the state of a local container as a new image.

D. docker import nginx:
This command is used to create a filesystem image from a tarball (an archive file). It is an alternative method for creating a base image, typically from a root filesystem, not for downloading a pre-built image from a registry.

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 the ability to use Docker commands to pull and manage container images.

Users report that connections to a MariaDB service are being closed unexpectedly. A systems administrator troubleshoots the issue and finds the following message in /var/log/messages:

Which of the following is causing the connection issue?


A.

The process mysqld is using too many semaphores.


B.

The server is running out of file descriptors.


C.

Something is starving the server resources.


D.

The amount of RAM allocated to the server is too high.





B.
  

The server is running out of file descriptors.



Summary:
The error message in the logs explicitly states "Too many open files" for the mysqld process. In Linux, every open file, socket, and pipe consumes a "file descriptor." Each process has a limit on the number of file descriptors it can open simultaneously. The MariaDB service (mysqld) has hit this limit, causing it to be unable to open new files or, critically, accept new network connections, which are also represented as file descriptors. This results in connections being closed or refused.

Correct Option:

B. The server is running out of file descriptors:
This is the direct interpretation of the "Too many open files" error. The mysqld process has exhausted its allocated file descriptors. This prevents it from establishing new client connections (as network sockets use file descriptors) and leads to the reported connection issues.

Incorrect Options:

A. The process mysqld is using too many semaphores:
While database servers do use semaphores for process synchronization, the error message clearly points to "open files," not semaphores. A semaphore-related error would generate a different kernel message.

C. Something is starving the server resources:
This is a vague and indirect description. While true in a broad sense (file descriptors are a resource), the specific, identifiable resource being starved is the number of available file descriptors for the mysqld process.

D. The amount of RAM allocated to the server is too high:
This is illogical. Having too much RAM would not cause a "Too many open files" error. If anything, insufficient RAM could cause swapping and performance issues, but the error message is explicitly about file descriptors, not memory.

Reference:
Linux man-pages project (getrlimit): The official documentation describes resource limits, including RLIMIT_NOFILE, which defines the maximum number of open file descriptors per process.

A Linux administrator needs to create a new cloud.cpio archive containing all the files from the current directory. Which of the following commands can help to accomplish this task?


A.

ls | cpio -iv > cloud.epio


B.

ls | cpio -iv < cloud.epio


C.

ls | cpio -ov > cloud.cpio


D.

ls cpio -ov < cloud.cpio





C.
  

ls | cpio -ov > cloud.cpio



Summary:
The administrator needs to create a new cpio archive named cloud.cpio containing all files in the current directory. The cpio command works by reading a list of file paths from standard input and can operate in different modes. The "copy-out" mode (-o) is used for creating archives. The correct command must create an archive and write the output to a file.

Correct Option:

C. ls | cpio -ov > cloud.cpio: This is the correct command.
ls generates the list of files in the current directory.

The pipe (|) sends this list to cpio.

-o puts cpio in "copy-out" mode to create an archive.

-v provides verbose output, listing the files being processed.

> cloud.cpio redirects the archive output to the file cloud.cpio.

Incorrect Options:

A. ls | cpio -iv > cloud.cpio:
The -i flag is for "copy-in" mode (extracting from an archive), not for creating one. This command would fail because it tries to extract from standard input while also redirecting output.

B. ls | cpio -iv < cloud.cpio:
This command uses the wrong mode (-i for extract) and the wrong redirection. The < symbol tries to use cloud.cpio as input for extraction, but the command also pipes a file list from ls, creating a conflict.

D. ls cpio -ov < cloud.cpio:
This command is syntactically incorrect. It tries to run ls with cpio as an argument and uses < for input redirection, which is the opposite of what's needed for creating an archive.

Reference:
Linux man-pages project (cpio): The official documentation explains the different operational modes: -o for create, -i for extract, and -p for pass-through.

An administrator installed an application from source into /opt/operations1/ and has received numerous reports that users are not able to access the application without having to use the full path /opt/operations1/bin/*. Which of the following commands should be used to resolve this issue?


A.

echo 'export PATH=$PATH:/opt/operations1/bin' >> /etc/profile


B.

echo 'export PATH=/opt/operations1/bin' >> /etc/profile


C.

echo 'export PATH=$PATH/opt/operations1/bin' >> /etc/profile


D.

echo 'export $PATH:/opt/operations1/bin' >> /etc/profile





A.
  

echo 'export PATH=$PATH:/opt/operations1/bin' >> /etc/profile



Summary:
Users cannot run the application without specifying its full path because the directory containing the binaries (/opt/operations1/bin/) is not included in the system's PATH environment variable. The PATH variable tells the shell where to look for executable files when a command is entered. The solution is to permanently add this directory to the PATH for all users.

Correct Option:

A. echo 'export PATH=$PATH:/opt/operations1/bin' >> /etc/profile:
This is the correct command. It appends a line to the global /etc/profile file, which is executed for all users during login. The syntax PATH=$PATH:/opt/operations1/bin correctly appends the new directory to the existing PATH variable, preserving all the existing search directories.

Incorrect Options:

B. echo 'export PATH=/opt/operations1/bin' >> /etc/profile:
This command would overwrite the entire PATH variable, replacing all standard directories (like /usr/bin, /bin) with only /opt/operations1/bin. This would break most system commands, as the shell would no longer know where to find common utilities like ls, cp, or mkdir.

C. echo 'export PATH=$PATH/opt/operations1/bin' >> /etc/profile:
This syntax is incorrect because it is missing the colon (:) that separates directories in the PATH variable. It would try to treat the value as a single, invalid directory path (e.g., /usr/bin:/bin/opt/operations1/bin).

D. echo 'export $PATH:/opt/operations1/bin' >> /etc/profile:
This command is invalid. The export keyword must be followed by a variable assignment (VAR=value), not by a variable expansion ($VAR). This would cause a syntax error.

Reference:
GNU Bash Manual (Bash Startup Files): The official documentation explains how /etc/profile is used for global environment configuration.

A systems administrator made some changes in the ~/.bashrc file and added an alias command. When the administrator tried to use the alias command, it did not work. Which of the following should be executed FIRST?


A.

source ~/.bashrc


B.

read ~/.bashrc


C.

touch ~/.bashrc


D.

echo ~/.bashrc





A.
  

source ~/.bashrc



Summary:
The administrator modified the ~/.bashrc file, which contains shell configuration commands, including the new alias. However, changes to this file are not automatically loaded into the current shell session. The shell only reads this file during its startup (e.g., when a new terminal is opened). To activate the changes in the current session without logging out and back in, the file must be explicitly read and executed by the shell.

Correct Option:

A. source ~/.bashrc:
This is the correct and standard command. The source command (which can also be written as . ~/.bashrc) reads and executes the commands from the specified file in the current shell environment. This will load the new alias definition, making it immediately available for use.

Incorrect Options:

B. read ~/.bashrc:
The read command is a shell builtin used to read a single line of input from standard input or a file descriptor into a variable. It is not used to execute commands from a file and will not load the alias.

C. touch ~/.bashrc:
The touch command is used to update a file's access and modification timestamps or to create an empty file. It does not read or execute the contents of the file and would have no effect on loading the alias.

D. echo ~/.bashrc:
The echo command simply prints its arguments to standard output. It would only display the path to the .bashrc file but would not process its contents or load the alias.

Reference:
Bash Reference Manual (Bourne Shell Builtins): The official documentation describes the source (or .) command for executing commands from a file in the current shell context.

A Linux administrator needs to harden a system and guarantee that the Postfix service will not run, even after a restart or system upgrade. Which of the following commands allows the administrator to fulfill the requirement?


A. systemctl mask postfix.service


B. systemctl disable postfix.service


C. systemctl stop postfix.service


D. systemctl -n restart postfix.service





A.
  systemctl mask postfix.service

Summary:
The Linux administrator must harden the system by ensuring the Postfix service remains disabled, even after restarts or system upgrades. This requires a method to prevent the service from being started under any circumstances, including automatic enablement during upgrades. The correct command must enforce a persistent block on the service's operation.

Correct Option:

A. systemctl mask postfix.service
systemctl mask postfix.service creates a symbolic link from the service file to /dev/null, preventing the service from being started or enabled, even by upgrades or manual attempts.

This ensures Postfix cannot run after a reboot or system upgrade, fulfilling the hardening requirement.

Unmasking (e.g., systemctl unmask postfix.service) is needed to reverse this action.

Incorrect Option:

B. systemctl disable postfix.service
systemctl disable postfix.service prevents the service from starting at boot but can be overridden by manual start or re-enabled during upgrades, not guaranteeing permanent disablement.

C. systemctl stop postfix.service
systemctl stop postfix.service halts the running service but does not prevent it from restarting on boot or after upgrades, making it insufficient for hardening.

D. systemctl -n restart postfix.service
systemctl -n is not a valid option; the correct flag might be --no-block, but even then, restart would attempt to restart Postfix, opposing the goal of disabling it. This is incorrect syntax and intent.

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

(Red Hat systemd management: https://access.redhat.com/documentation)

During a security scan, the password of an SSH key file appeared to be too weak and was cracked. Which of the following commands would allow a user to choose a stronger password and set it on the existing SSH key file?


A. passwd


B. ssh


C. ssh-keygen


D. pwgen





C.
  ssh-keygen

Summary:
An SSH private key file can be encrypted with a passphrase for an additional layer of security. If this passphrase is weak and gets cracked, the user needs a way to change it to a stronger one without generating a whole new key pair. The tool used to create SSH keys also has the functionality to change the passphrase on an existing private key.

Correct Option:

C. ssh-keygen:
This is the correct command. The ssh-keygen tool, which is used to generate new SSH key pairs, can also change the passphrase of an existing private key. The command ssh-keygen -p -f /path/to/private_key will prompt the user for the old passphrase and then for a new, stronger one, thereby re-encrypting the private key file with the new password.

Incorrect Options:

A. passwd:
This command is used to change the login password of a user account on the Linux system. It has no effect on the passphrase of an SSH key file, which is a separate form of encryption on the key file itself.

B. ssh:
This command is used to initiate SSH connections to remote servers. It does not have a sub-command or functionality for managing or changing key passphrases.

D. pwgen:
This is a utility for generating random passwords. It can be used to create a strong password, but it cannot set that password on the SSH key file. The user would still need to use ssh-keygen to apply the newly generated password to the key.

Reference:
Official CompTIA Linux+ (XK0-005) Certification Exam Objectives: This scenario falls under Objective 4.2: "Given a scenario, implement and configure Linux firewalls and access control options," which includes managing SSH and key-based authentication. Knowing how to use ssh-keygen to manage key passphrases is a fundamental security practice.

A Linux administrator logs in to a system and identifies that an important backup has been started. The backup process is consuming a considerable amount of CPU time but needs to continue. Which of the following should the administrator use to reduce the impact this process has on other services?


A. renice -n 15 -p


B. nice -n 15 -p


C. renice -n -15 -p


D. nice -n -15 -p





A.
  renice -n 15 -p

Summary:
A backup process is already running and consuming high CPU, impacting other services. The administrator needs to lower its priority so it is "nicer" to other processes, freeing up CPU resources for other services without stopping the backup. This requires changing the "nice" value of an existing process. A higher nice value means a lower priority.

Correct Option:

A. renice -n 15 -p :
This is the correct command.

renice is used to change the priority of an already running process.

-n 15 sets the new nice value to 15, which is the lowest priority (most "nice").

-p specifies the Process ID of the backup process to modify.

Incorrect Options:

B. nice -n 15 -p :
The nice command is used to start a new process with a modified priority. It cannot be used to change the priority of an existing process. The -p flag is invalid for nice.

C. renice -n -15 -p :
This command would set the nice value to -15, which is a very high priority. This would make the backup process more aggressive in consuming CPU, worsening the impact on other services.

D. nice -n -15 -p :
This is incorrect for two reasons. First, nice is for starting new processes. Second, it sets a high priority (-15), which is the opposite of what is needed.

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 process execution priorities. Knowing the distinction between nice (for new processes) and renice (for existing processes) and that a higher nice value means a lower priority is a key skill.

A Linux administrator wants a permission bit on a shared folder that allows only the owner of the file within that directory or the root user to delete or rename the file. Which of the following commands will help achieve this goal?


A. chmod u-w /directory/


B. chmod a-r /directory/


C. chmod o-t /directory/


D. chmod +t /directory/





D.
  chmod +t /directory/

Summary:
This question focuses on setting a permission bit on a shared folder to restrict file deletion or renaming to only the file owner or root user. The task requires understanding special permissions in Linux, particularly the sticky bit, which protects files in shared directories. The correct command must apply this bit to ensure security while allowing normal access for other users.

Correct Option:

D. chmod +t /directory/
The chmod +t command sets the sticky bit on /directory/, restricting deletion or renaming of files to only the file owner or root, even if others have write permissions.

This is ideal for shared folders where multiple users have write access but should not delete each other’s files.

The sticky bit is commonly used for directories like /tmp to enforce this behavior.

Incorrect Option:

A. chmod u-w /directory/
The chmod u-w command removes write permission from the owner of the directory, preventing the owner from creating, deleting, or renaming files.

This undermines the goal of allowing the owner to manage their files, making it an incorrect choice.

B. chmod a-r /directory/
The chmod a-r command removes read permission for all users (owner, group, others), preventing anyone from listing or accessing files in the directory.

This is too restrictive and doesn’t address the specific need to limit deletion/renaming, rendering it unsuitable.

C. chmod o-t /directory/
The chmod o-t command removes the sticky bit for others, but the question implies the sticky bit isn’t set yet and needs to be added.

Removing a non-existent sticky bit has no effect, and this doesn’t achieve the desired restriction, making it incorrect.

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

An administrator is running a web server in a container named WEB, but none of the error output is showing. Which of the following should the administrator use to generate the errors on the container?


A. docker-compose inspect WEB


B. docker logs WEB


C. docker run --name WEB --volume /dev/stdout:/var/log/nginx/error.log


D. docker ps WEB -f





B.
  docker logs WEB

Summary:
The administrator is running a containerized web server, but the error output is not visible. Containers by default write their output (stdout and stderr) to a logging driver, which can be viewed using a specific Docker command. The correct command must be one that retrieves and displays the log output that the container has generated since it started.

Correct Option:

B. docker logs WEB:
This is the correct command. The docker logs command fetches the logs of a container. It will show the standard output (stdout) and standard error (stderr) messages that the application inside the container has written. This is the primary method for troubleshooting and viewing the output of a running or stopped container. (Note: The command should be docker logs web if the container name is case-sensitive and actually web).

Incorrect Options:

A. docker-compose inspect WEB:
The docker-compose inspect command is used to view the configuration of a service defined in a docker-compose.yml file. It returns low-level configuration data in JSON format, not the runtime log output of the application.

C. docker run —name WEB —volume /dev/stdout:/var/log/nginx/error.log:
This is a command to create and start a new container, not to view the logs of an existing one. While the volume mount trick can be used to redirect a log file to stdout, it is a method for configuring a new container, not for viewing logs from an already running container named web.

D. docker ps WEB -f:
The docker ps command is used to list running containers. The -f flag is for filtering the list. This command would try to list containers with the name WEB, but it would not display any log output. It is a diagnostic command for checking container status, not for retrieving logs.

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 manage containers. The docker logs command is the fundamental tool for troubleshooting containerized applications by viewing their output.


Page 15 out of 40 Pages
Previous