Practice Free XK0-005 Exam Online Questions
A systems administrator wants to check for running containers.
Which of the following commands can be used to show this information?
- A . docker pull
- B . docker stats
- C . docker ps
- D . docker list
C
Explanation:
The command that can be used to check for running containers is docker ps. The docker ps command can list all the containers that are currently running on the system. To show all the containers, including those that are stopped, the administrator can use docker ps -a ©. :
[CompTIA Linux+ Study Guide], Chapter 11: Working with Containers, Section: Managing Containers with Docker
[Docker PS Command with Examples]
An administrator wants to execute a long-running script in the terminal while troubleshooting another issue.
Which of the following options will achieve this goal?
- A . bash script.sh &
- B . source script.sh
- C . sh script.sh | jobs
- D . nice -10 ./script.sh
A
Explanation:
Running a command with & at the end sends it to the background, allowing the administrator to continue using the terminal for other tasks while the script runs. This is useful for long-running scripts that do not require immediate attention but need to keep running.
Reference: Linux Background Jobs
A systems administrator created a web server for the company and is required to add a tag for the API so end users can connect.
Which of the following would the administrator do to complete this requirement?
- A . hostnamectl status –no-ask-password
- B . hostnamectl set-hostname "$(perl -le "print" "A" x 86)"
- C . hostnamectl set-hostname Comptia-WebNode -H [email protected]
- D . hostnamectl set-hostname Comptia-WebNode –transient
C
Explanation:
The command hostnamectl set-hostname Comptia-WebNode -H [email protected] sets the hostname of the web server to Comptia-WebNode and connects to the server using the SSH protocol and the root user. This is the correct way to complete the requirement. The other options are incorrect because they either display the current hostname status (hostnamectl status), set an invalid hostname (hostnamectl set-hostname "$(perl -le "print" "A" x 86)"), or set a transient hostname that is not persistent (hostnamectl set-hostname Comptia-WebNode –transient). CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 9: Managing System Components, page 291.
Which of the following Git commands would send committed changes to a remote repository?
- A . git stash
- B . git commit -a
- C . git push origin master
- D . git add
C
Explanation:
Comprehensive and Detailed Step-by-Step
git push origin master pushes committed changes to the remote repository.
git stash temporarily saves changes but does not push them.
git commit -a commits changes but does not send them to the remote repository.
git add. stages changes but does not commit or push them.
Reference: CompTIA Linux+ Official Study Guide, Chapter on Git and Version Control
A Linux administrator needs to analyze a failing application that is running inside a container.
Which of the following commands allows the Linux administrator to enter the running container and analyze the logs that are stored inside?
- A . docker run -ti app /bin/sh
- B . podman exec -ti app /bin/sh
- C . podman run -d app /bin/bash
- D . docker exec -d app /bin/bash
B
Explanation:
Podman exec -ti app /bin/sh allows the Linux administrator to enter the running container and analyze the logs that are stored inside. This command uses the podman tool, which is a daemonless container engine that can run and manage containers on Linux systems. The exec option executes a command inside an existing container, in this case app, which is the name of the container that runs the failing application. The -ti option allocates a pseudo-TTY and keeps STDIN open, allowing for interactive shell access to the container. The /bin/sh argument specifies the shell command to run inside the container, which can be used to view and manipulate the log files.
The other options are not correct commands for entering a running container and analyzing the logs. Docker run -ti app /bin/sh creates a new container from the app image and runs the /bin/sh command inside it, but does not enter the existing container that runs the failing application. Podman run -d app /bin/bash also creates a new container from the app image and runs the /bin/bash command inside it, but does so in detached mode, meaning that it runs in the background without interactive shell access. Docker exec -d app /bin/bash executes the /bin/bash command inside the existing app container, but also does so in detached mode, without interactive shell access.
: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 18: Automating Tasks; View container logs | Docker Docs; How to see the logs of a docker container – Stack Overflow
A user created the following script file:
# ! /bin/bash
# FILENAME: /home/user/ script. sh echo "hello world"
exit 1
However, when the user tried to run the script file using the command "script. sh, an error returned indicating permission was denied.
Which of the follow-ing should the user execute in order for the script to run properly?
- A . chmod u+x /home/user/script. sh
- B . chmod 600 /home/user/script. sh
- C . chmod /home/user/script. sh
- D . chmod 0+r /horne/user/script. sh
A
Explanation:
To run a script file, the user needs to have execute permission on the file. The command chmod u+x /home/user/script.sh (A) will grant execute permission to the owner of the file, which is the user who created it. The other commands will not give execute permission to the user, and therefore will not allow the script to run properly.
[CompTIA Linux+ Study Guide], Chapter 3: Working with Files, Section: Changing File Permissions [How to Make a Bash Script Executable]
Which of the following commands can be used to manage RPM software packages? (Choose two.
- A . dpkg
- B . yum
- C . apt
- D . rpm
A systems administrator installed a new software program on a Linux server.
When the systems administrator tries to run the program, the following message appears on the screen.
Which of the following commands will allow the systems administrator to check whether the system supports virtualization?
- A . dmidecode -s system-version
- B . lscpu
- C . sysctl -a
- D . cat /sys/device/system/cpu/possible
B
Explanation:
The command that will allow the systems administrator to check whether the system supports virtualization is lscpu. This command will display information about the CPU architecture, such as the number of CPUs, cores, sockets, threads, model name, frequency, cache size, and flags. One of the flags is vmx (for Intel processors) or svm (for AMD processors), which indicates that the CPU supports hardware virtualization. If the flag is present, it means that the system supports virtualization. If the flag is absent, it means that the system does not support virtualization or that it is disabled in the BIOS settings.
The other options are not correct commands for checking whether the system supports virtualization. The dmidecode -s system-version command will display the version of the system, such as the product name or serial number, but not the CPU information. The sysctl -a command will display all the kernel parameters, but not the CPU flags. The cat /sys/devices/system/cpu/possible command will display the range of possible CPUs that can be online or offline, but not the CPU features. lscpu(1) – Linux manual page; How To Check If Virtualization is Enabled in Windows 10 / 11
A systems administrator identifies multiple processes in a zombie state.
Which of the following signals would be best for the administrator to send to the PPID?
- A . SIGTERM
- B . SIGHUP
- C . SIGQUIT
- D . SIGSTOP
A
Explanation:
A zombie process is a process that has completed execution but still has an entry in the process table because its parent process has not read its exit status. The best signal to send to the parent process is SIGTERM, which politely asks it to terminate and release the resources held by the zombie child processes.
The development team created a new branch with code changes that a Linux administrator needs to pull from the remote repository. When the administrator looks for the branch in Git, the branch in question is not visible.
Which of the following commands should the Linux administrator run to refresh the branch information?
- A . git fetch
- B . git checkout
- C . git clone
- D . git branch
A
Explanation:
The git fetch command downloads commits, files, and refs from a remote repository into the local one. It also updates the remote-tracking branches, which are references to the state of the remote branches. By running git fetch, the administrator can see the new branch created by the development team and then use git checkout to switch to it12.
1: Git – git-fetch Documentation 2: Git Fetch | Atlassian Git Tutorial