ExamGecko
Home Home / CompTIA / XK0-005

CompTIA XK0-005 Practice Test - Questions Answers, Page 26

Question list
Search
Search

List of questions

Search

Related questions











A technician just fixed a few issues in some code and is ready to deploy the code into production. Which of the following steps should the technician take next?

A.
Create a new branch using git checkout.
A.
Create a new branch using git checkout.
Answers
B.
Perform a git clone to pull main down.
B.
Perform a git clone to pull main down.
Answers
C.
Create a git pull request to merge into main.
C.
Create a git pull request to merge into main.
Answers
D.
Perform a git pull to update the local copy of the code.
D.
Perform a git pull to update the local copy of the code.
Answers
Suggested answer: C

Explanation:

After fixing issues in the code, the next step is to merge these changes into the main branch.This is typically done by creating a pull request78.

Reference: 7(https://zeet.co/blog/deploy-to-production) 8(https://stackoverflow.com/questions/11833511/git-deploy-to-production)

An administrator accidentally installed the httpd RPM package along with several dependencies. Which of the following options is the best way for the administrator to revert the package installation?

A.
dnf clean all
A.
dnf clean all
Answers
B.
rpm -e httpd
B.
rpm -e httpd
Answers
C.
apt-get clean
C.
apt-get clean
Answers
D.
yum history undo last
D.
yum history undo last
Answers
Suggested answer: D

Explanation:

The yum history undo last command will undo the last transaction, which in this case is the installation of the httpd RPM package and its dependencies. This will remove the packages that were installed and restore the previous state of the system. SeeHow to undo or redo yum transactionsandyum history. Reference 1: https://www.redhat.com/sysadmin/undo-redo-yum-transactions 2: https://man7.org/linux/man-pages/man8/yum.8.html#HISTORY


A Linux administrator generated a list of users who have root-level command-line access to the Linux server to meet an audit requirement. The administrator analyzes the following /etc/passwd and /etc/sudoers files:

$ cat /etc/passwd

root:x: 0:0: :/home/root: /bin/bash

lee: x: 500: 500: :/home/lee:/bin/tcsh

mallory:x: 501:501: :/root:/bin/bash

eve:x: 502: 502: /home/eve:/bin/nologin

carl:x:0:503: :/home/carl:/bin/sh

bob:x: 504: 504: : /home/bob:/bin/ksh

alice:x: 505:505: :/home/alice:/bin/rsh

$ cat /etc/sudoers

Cmnd_Alias SHELLS = /bin/tcsh, /bin/sh, /bin/bash

Cmnd_Alias SYSADMIN = /usr/sbin/tcpdump

ALL = (ALL) ALL

ALL = NOPASSWD: SYSADMIN

Which of the following users, in addition to the root user, should be listed in the audit report as having root-level command-line access? (Select two).

A.
Carl
A.
Carl
Answers
B.
Lee
B.
Lee
Answers
C.
Mallory
C.
Mallory
Answers
D.
Eve
D.
Eve
Answers
E.
Bob
E.
Bob
Answers
F.
Alice
F.
Alice
Answers
Suggested answer: A, C

Explanation:

The users who have root-level command-line access are those who have either the same user ID (UID) as root, which is 0, or the ability to run commands as root using sudo. Based on the /etc/passwd and /etc/sudoers files, the users who meet these criteria are:

Carl: Carl has the same UID as root, which is 0, as shown in the /etc/passwd file. This means that Carl can log in as root and execute any command with root privileges1

Mallory: Mallory has the ability to run commands as root using sudo, as shown in the /etc/sudoers file. The line ALL = (ALL) ALL means that any user can run any command as any other user, including root, by using sudo. Mallory can also use the root shell /bin/bash as her login shell, as shown in the /etc/passwd file2

Therefore, the correct answer is A and C. Lee, Eve, Bob, and Alice do not have root-level command-line access because they have different UIDs from root and they cannot use sudo to run commands as root. Lee can only use sudo to run the commands listed in the Cmnd_Alias SHELLS, which are /bin/tcsh, /bin/sh, and /bin/bash. Eve cannot log in at all because her login shell is /bin/nologin. Bob and Alice can only use sudo to run the command /usr/sbin/tcpdump without a password, as specified by the Cmnd_Alias SYSADMIN and the line ALL = NOPASSWD: SYSADMIN2

A systems administrator is configuring a Linux system so the network traffic from the internal network 172.17.0.0/16 going out through the eth0 interface would appear as if it was sent directly from this interface. Which of the following commands will accomplish this task?

A.
iptables -A POSTROUTING -s 172.17.0.0/16 -o eth0 -j MASQUERADE
A.
iptables -A POSTROUTING -s 172.17.0.0/16 -o eth0 -j MASQUERADE
Answers
B.
firewalld -A OUTPUT -s 172.17.0.0/16 -o eth0 -j DIRECT
B.
firewalld -A OUTPUT -s 172.17.0.0/16 -o eth0 -j DIRECT
Answers
C.
nmcli masq-traffic eth0 -s 172.17.0.0/16 -j MASQUERADE
C.
nmcli masq-traffic eth0 -s 172.17.0.0/16 -j MASQUERADE
Answers
D.
ifconfig -- nat eth0 -s 172.17.0.0/16 -j DIRECT
D.
ifconfig -- nat eth0 -s 172.17.0.0/16 -j DIRECT
Answers
Suggested answer: A

Explanation:

This command will use the iptables tool to append a rule to the POSTROUTING chain of the nat table, which will match any packet with a source address of 172.17.0.0/16 and an output interface of eth0, and apply the MASQUERADE target to it.This means that the packet will have its source address changed to the address of the eth0 interface, effectively hiding the internal network behind a NAT12.

A user is unable to log on to a Linux workstation. The systems administrator executes the following command:

cat /etc/shadow | grep user1

The command results in the following output:

user1 :! $6$QERgAsdvojadv4asdvaarC/9dj34GdafGVaregmkdsfa:18875:0:99999:7 :::

Which of the following should the systems administrator execute to fix the issue?

A.
chown -R userl:user1 /home/user1
A.
chown -R userl:user1 /home/user1
Answers
B.
sed -i '/ ::: / :: /g' /etc/shadow
B.
sed -i '/ ::: / :: /g' /etc/shadow
Answers
C.
chgrp user1:user1 /home/user1
C.
chgrp user1:user1 /home/user1
Answers
D.
passwd -u user1
D.
passwd -u user1
Answers
Suggested answer: D

Explanation:

The output shows that the user1 account has a locked password, indicated by the exclamation point (!) in the second field of the /etc/shadow file1.To unlock the password and allow the user to log in, the systems administrator should use the passwd command with the -u (unlock) option2.

A Linux engineer finds multiple failed login entries in the security log file for application users. The Linux engineer performs a security audit and discovers a security issue. Given the following:

# grep -iE '*www*|db' /etc/passwd

www-data:x:502:502:www-data:/var/www:/bin/bash

db:x: 505:505:db: /opt/db:/bin/bash

Which of the following commands would resolve the security issue?

A.
usermod -d /srv/www-data www-data && usermod -d /var/lib/db db
A.
usermod -d /srv/www-data www-data && usermod -d /var/lib/db db
Answers
B.
passwd -u www-data && passwd -u db
B.
passwd -u www-data && passwd -u db
Answers
C.
renice -n 1002 -u 502 && renice -n 1005 -u 505
C.
renice -n 1002 -u 502 && renice -n 1005 -u 505
Answers
D.
chsh -s /bin/false www-data && chsh -s /bin/false db
D.
chsh -s /bin/false www-data && chsh -s /bin/false db
Answers
Suggested answer: D

Explanation:

This command will use the chsh tool to change the login shell of the users www-data and db to /bin/false, which means they will not be able to log in to the system1. This will prevent unauthorized access attempts and improve security.

A Linux administrator has defined a systemd script docker-repository.mount to mount a volume for use by the Docker service. The administrator wants to ensure that Docker service does not start until the volume is mounted. Which of the following configurations needs to be added to the Docker service definition to best accomplish this task?

A.
After=docker-respository.mount
A.
After=docker-respository.mount
Answers
B.
ExecStart=/usr/bin/mount -a
B.
ExecStart=/usr/bin/mount -a
Answers
C.
Requires=docker-repository.mount
C.
Requires=docker-repository.mount
Answers
D.
RequiresMountsFor=docker-repository.mount
D.
RequiresMountsFor=docker-repository.mount
Answers
Suggested answer: C

Explanation:

This option declares an explicit dependency between the Docker service and the docker-repository.mount unit. It means that the Docker service will not start unless the docker-repository.mount unit is successfully activated.This ensures that the volume is mounted before the Docker service tries to use it12.

Which of the following will prevent non-root SSH access to a Linux server?

A.
Creating the /etc/nologin file
A.
Creating the /etc/nologin file
Answers
B.
Creating the /etc/nologin.allow file containing only a single line root
B.
Creating the /etc/nologin.allow file containing only a single line root
Answers
C.
Creating the /etc/nologin/login.deny file containing a single line +all
C.
Creating the /etc/nologin/login.deny file containing a single line +all
Answers
D.
Ensuring that /etc/pam.d/sshd includes account sufficient pam_nologin.so
D.
Ensuring that /etc/pam.d/sshd includes account sufficient pam_nologin.so
Answers
Suggested answer: A

Explanation:

This file prevents any non-root user from logging in to the system, regardless of the authentication method. The contents of the file are displayed to the user before the login is terminated.This can be useful for system maintenance or security reasons12.

A systems administrator is working on a security report from the Linux servers. Which of the following commands can the administrator use to display all the firewall rules applied to the Linux servers? (Select two).

A.
ufw limit
A.
ufw limit
Answers
B.
iptables ---F
B.
iptables ---F
Answers
C.
systemct1 status firewalld
C.
systemct1 status firewalld
Answers
D.
firewall---cmd ------1ist---a11
D.
firewall---cmd ------1ist---a11
Answers
E.
ufw status
E.
ufw status
Answers
F.
iptables ---A
F.
iptables ---A
Answers
Suggested answer: D, E

Explanation:

These commands can display all the firewall rules applied to the Linux servers, depending on which firewall service is being used.

The firewall-cmd command is a utility for managing firewalld, which is a dynamic firewall service that supports zones and services. The --list-all option will show all the settings and rules for the default zone, or for a specific zone if specified.For example, firewall-cmd --list-all --zone=public will show the rules for the public zone1.

The ufw command is a frontend for iptables, which is a low-level tool for manipulating netfilter, the Linux kernel's packet filtering framework. The status option will show the status of ufw and the active rules, or the numbered rules if verbose is specified.For example, ufw status verbose will show the numbered rules and other information2.

The other options are incorrect because:

A) ufw limit

This command will limit the connection attempts to a service or port using iptables' recent module.It does not display any firewall rules2.

B) iptables -F

This command will flush (delete) all the rules in the selected chain, or all chains if none is given.It does not display any firewall rules3.

C) systemctl status firewalld

This command will show the status of the firewalld service, including whether it is active or not, but it does not show the firewall rules4.

F) iptables -A

This command will append one or more rules to the end of the selected chain.It does not display any firewall rules3.

An administrator needs to make an application change via a script that must be run only in console mode. Which of the following best represents the sequence the administrator should execute to accomplish this task?

A.
systemct1 isolate multi-user.target sh script.sh systemct1 isolate graphical.target
A.
systemct1 isolate multi-user.target sh script.sh systemct1 isolate graphical.target
Answers
B.
systemct1 isolate graphical.target sh script.sh systemct1 isolate multi-user.target
B.
systemct1 isolate graphical.target sh script.sh systemct1 isolate multi-user.target
Answers
C.
sh script.sh systemct1 isolate multi-user.target systemct1 isolate graphical.target
C.
sh script.sh systemct1 isolate multi-user.target systemct1 isolate graphical.target
Answers
D.
systemct1 isolate multi-user.target systemct1 isolate graphical.target sh script.sh
D.
systemct1 isolate multi-user.target systemct1 isolate graphical.target sh script.sh
Answers
Suggested answer: A

Explanation:

The correct answer is A. systemctl isolate multi-user.target sh script.sh systemctl isolate graphical.target

This sequence will allow the administrator to switch from the graphical mode to the console mode, run the script, and then switch back to the graphical mode.

The systemctl command is used to control the systemd system and service manager, which manages the boot targets and services on Linux systems. The isolate subcommand starts the unit specified on the command line and its dependencies and stops all others. The multi-user.target is a boot target that provides a text-based console login, while the graphical.target is a boot target that provides a graphical user interface. By using systemctl isolate, the administrator can change the boot target on the fly without rebooting the system.

The sh command is used to run a shell script, which is a file that contains a series of commands that can be executed by the shell. The script.sh is the name of the script that contains the application change that the administrator needs to make. By running sh script.sh, the administrator can execute the script in the console mode.

The other options are incorrect because:

B) systemctl isolate graphical.target sh script.sh systemctl isolate multi-user.target

This sequence will switch from the console mode to the graphical mode, run the script, and then switch back to the console mode. This is not what the administrator wants to do, as the script must be run only in console mode.

C) sh script.sh systemctl isolate multi-user.target systemctl isolate graphical.target

This sequence will run the script in the current mode, which may or may not be console mode, and then switch to console mode and back to graphical mode. This is not what the administrator wants to do, as the script must be run only in console mode.

D) systemctl isolate multi-user.target systemctl isolate graphical.target sh script.sh

This sequence will switch from graphical mode to console mode and then back to graphical mode, without running the script at all. This is not what the administrator wants to do, as the script must be run only in console mode.

systemctl(1) - Linux manual page

How to switch between the CLI and GUI on a Linux server

How to PROPERLY boot into single user mode in RHEL/CentOS 7/8

Changing Systemd Boot Target in Linux

Exit Desktop to Terminal in Ubuntu 19.10

Total 371 questions
Go to page: of 38