Practice Free XK0-005 Exam Online Questions
A Linux administrator was asked to run a container with the httpd server inside. This container should be exposed at port 443 of a Linux host machine while it internally listens on port 8443.
Which of the following commands will accomplish this task?
- A . podman run -d -p 443:8443 httpd
- B . podman run -d -p 8443:443 httpd
- C . podman run Cd -e 443:8443 httpd
- D . podman exec -p 8443:443 httpd
A
Explanation:
The command that will accomplish the task of running a container with the httpd server inside and exposing it at port 443 of the Linux host machine while it internally listens on port 8443 is podman run -d -p 443:8443 httpd. This command uses the podman tool, which is a daemonless container engine that can run and manage containers on Linux systems. The -d option runs the container in detached mode, meaning that it runs in the background without blocking the terminal. The -p option maps a port on the host machine to a port inside the container, using the format host_port:container_port. In this case, port 443 on the host machine is mapped to port 8443 inside the container, allowing external access to the httpd server. The httpd argument specifies the name of the image to run as a container, which in this case is an image that contains the Apache HTTP Server software. The other options are not correct commands for accomplishing the task. Podman run -d -p 8443:443 httpd maps port 8443 on the host machine to port 443 inside the container, which does not match the requirement. Podman run Cd -e 443:8443 httpd uses the -e option instead of the -p option, which sets an environment variable inside the container instead of mapping a port. Podman exec -p 8443:443 httpd uses the podman exec command instead of the podman run command, which executes a command inside an existing container instead of creating a new one.
Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 18: Automating Tasks
Due to low disk space, a Linux administrator finding and removing all log files that were modified more than 180 days ago.
Which of the following commands will accomplish this task?
- A . find /var/log -type d -mtime +180 -print -exec rm {} ;
- B . find /var/log -type f -modified +180 -rm
- C . find /var/log -type f -mtime +180 -exec rm {}
- D . find /var/log -type c -atime +180 Cremove
C
Explanation:
The command that will accomplish the task of finding and removing all log files that were modified more than 180 days ago is find /var/log -type f -mtime +180 -exec rm {} ;. This command will use find to search for files (-type f) under /var/log directory that have a modification time (-mtime) older than 180 days (+180). For each matching file, it will execute (-exec) the rm command to delete it, passing the file name as an argument ({}). The command will end with a semicolon (;), which is escaped with a backslash to prevent shell interpretation.
The other options are not correct commands for accomplishing the task. The find /var/log -type d – mtime +180 -print -exec rm {} ; command will search for directories (-type d) instead of files, and print their names (-print) before deleting them. This is not what the task requires. The find /var/log – type f -modified +180 -rm command is invalid because there is no such option as -modified or -rm for find. The correct options are -mtime and -delete, respectively. The find /var/log -type c -atime +180 C remove command is also invalid because there is no such option as Cremove for find. Moreover, it will search for character special files (-type c) instead of regular files, and use access time (-atime) instead of modification time.
Reference: find(1) – Linux manual page; Find and delete files older than n days in Linux
A Linux administrator wants to display a list of all containers, including ones that are stopped.
Which of the following commands should the administrator run?
- A . docker ps -a
- B . docker image list
- C . docker stats
- D . docker list -a
An administrator added the port 2222 for the SSH server on myhost and restarted the SSH server. The administrator noticed issues during the startup of the service.
Given the following outputs:
Which of the following commands will fix the issue?
- A . semanage port -a -t ssh_port_t -p tcp 2222
- B . chcon system_u:object_r:ssh_home_t /etc/ssh/*
- C . iptables -A INPUT -p tcp — dport 2222 -j ACCEPT
- D . firewall-cmd — zone=public — add-port=2222/tcp
A
Explanation:
The correct answer is A. semanage port -a -t ssh_port_t -p tcp 2222
This command will allow the SSH server to bind to port 2222 by adding it to the SELinux policy. The semanage command is a utility for managing SELinux policies. The port subcommand is used to manage network port definitions. The -a option is used to add a new record, the -t option is used to specify the SELinux type, the -p option is used to specify the protocol, and the tcp 2222 argument is used to specify the port number. The ssh_port_t type is the default type for SSH ports in SELinux. The other options are incorrect because:
B. chcon system_u:object_r:ssh_home_t /etc/ssh/*
This command will change the SELinux context of all files under /etc/ssh/ to system_u:object_r:ssh_home_t, which is not correct. The ssh_home_t type is used for user home directories that are accessed by SSH, not for SSH configuration files. The correct type for SSH configuration files is sshd_config_t.
C. iptables -A INPUT -p tcp –dport 2222 -j ACCEPT
This command will add a rule to the iptables firewall to accept incoming TCP connections on port 2222. However, this is not enough to fix the issue, as SELinux will still block the SSH server from binding to that port. Moreover, iptables may not be the default firewall service on some Linux distributions, such as Fedora or CentOS, which use firewalld instead.
D. firewall-cmd –zone=public –add-port=2222/tcp
This command will add a rule to the firewalld firewall to allow incoming TCP connections on port 2222 in the public zone. However, this is not enough to fix the issue, as SELinux will still block the SSH server from binding to that port. Moreover, firewalld may not be installed or enabled on some Linux distributions, such as Ubuntu or Debian, which use iptables instead.
Reference: How to configure SSH to use a non-standard port with SELinux set to enforcing Change SSH Port on CentOS/RHEL/Fedora With SELinux Enforcing How to change SSH port when SELinux policy is enabled
A User on a Linux workstation needs to remotely start an application on a Linux server and then forward the graphical display of that application back to the Linux workstation.
Which of the following would enable the user to perform this action?
- A . ssh -X user@server application
- B . ssh -y user@server application
- C . ssh user@server application
- D . ssh -D user@server application
A
Explanation:
The ssh -X option enables X11 forwarding, which allows the user to run graphical applications on the remote server and display them on the local workstation. The user needs to specify the username, the server address, and the application name after the ssh -X command. The remote server also needs to have X11Forwarding enabled and xauth installed for this to work.
Reference: The web search result 8 explains how to run a GUI application through SSH by configuring both the SSH client and server.
The web search result 6 provides a detailed answer on how to forward X over SSH to run graphics applications remotely, with examples and troubleshooting tips.
The CompTIA Linux+ Certification Exam Objectives mention that the candidate should be able to “use SSH for remote access and management” as part of the System Operation and Maintenance domain1.
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.
Reference: lscpu(1) – Linux manual page; How To Check If Virtualization is Enabled in Windows 10 / 11
After installing a new version of a package, a systems administrator notices a new version of the corresponding, service file was Installed.
In order to use the new version of the, service file, which of the following commands must be Issued FIRST?
- A . systemct1 status
- B . systemct1 stop
- C . systemct1 reinstall
- D . systemct1 daemon-reload
D
Explanation:
After installing a new version of a package that includes a new version of the corresponding service file, the systemct1 daemon-reload command must be issued first in order to use the new version of the service file. This command will reload the systemd manager configuration and read all unit files that have changed on disk. This will ensure that systemd recognizes the new service file and applies its settings correctly. The systemct1 status command will display information about a service unit, but it will not reload the configuration. The systemct1 stop command will stop a service unit, but it will not reload the configuration. The systemct1 reinstall command does not exist.
Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 17: System Maintenance and Operation, page 518.
A user sends a request to access a virtual server via SSH.
Which of the following commands is used to open the SSH standard port?
- A . firewalld-cmd –permanent –add-port=22/tcp
- B . iptables-save | grep dport-22/tcp
- C . iptables -A INPUT -p tcp –dport sshd -j ACCEPT
- D . firewalld-cmd –remove-service=ssh –permanent
A systems administrator needs to check if the service systemd-resolved.service is running without any errors.
Which of the following commands will show this information?
- A . systemct1 status systemd-resolved.service
- B . systemct1 enable systemd-resolved.service
- C . systemct1 mask systemd-resolved.service
- D . systemct1 show systemd-resolved.service
A
Explanation:
The command systemct1 status systemd-resolved.service will show the information about the service systemd-resolved.service. The systemct1 command is a tool for managing system services and units. The status option displays the current status of a unit, such as active, inactive, or failed. The output also shows the unit description, loaded configuration, process ID, memory usage, and recent log messages. This command will show if the service systemd-resolved.service is running without any errors. This is the correct command to use to accomplish the task. The other options are incorrect because they either perform different actions (enable, mask, or show) or do not show the status of the service (systemct1 show systemd-resolved.service only shows the properties of the service, not the status).
Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 14: Managing Processes and Scheduling Tasks, page 427.
An administrator runs ping comptia.org.
The result of the command is:
ping: comptia.org: Name or service not known
Which of the following files should the administrator verify?
- A . /etc/ethers
- B . /etc/services
- C . /etc/resolv.conf
- D . /etc/sysctl.conf
C
Explanation:
The best file to verify when the ping command returns the error “Name or service not known” is C. /etc/resolv.conf. This file contains the configuration for the DNS resolver, which is responsible for translating domain names into IP addresses. If this file is missing, corrupted, or has incorrect entries, the ping command will not be able to resolve the domain name and will fail with the error. To fix this issue, the administrator should check that the file exists, has proper permissions, and has valid nameserver entries. For example, a typical /etc/resolv.conf file may look like this: nameserver 8.8.8.8 nameserver 8.8.4.4
These are the IP addresses of Google’s public DNS servers, which can be used as a fallback option if the default DNS servers are not working.