ExamGecko
Home Home / CompTIA / XK0-005

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

Question list
Search
Search

List of questions

Search

Related questions











A systems administrator wants to be sure the sudo rules just added to /etc/sudoers are valid. Which of the following commands can be used for this task?

A.
visudo -c
A.
visudo -c
Answers
B.
test -f /etc/sudoers
B.
test -f /etc/sudoers
Answers
C.
sudo vi check
C.
sudo vi check
Answers
D.
cat /etc/sudoers | tee test
D.
cat /etc/sudoers | tee test
Answers
Suggested answer: A

Explanation:

The command visudo -c can be used to check the validity of the sudo rules in the /etc/sudoers file.

The visudo command is a tool for editing and validating the /etc/sudoers file, which defines the rules for the sudo command. The -c option checks the syntax and logic of the file and reports any errors or warnings. The command visudo -c will verify the sudo rules and help the administrator avoid any mistakes. This is the correct command to use for this task. The other options are incorrect because they either do not check the validity of the file (test, sudo, or cat) or do not exist (sudo vi check). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 18: Securing Linux Systems, page 546.

A user generated a pair of private-public keys on a workstation. Which of the following commands will allow the user to upload the public key to a remote server and enable passwordless login?

A.
scp ~/.ssh/id_rsa user@server:~/
A.
scp ~/.ssh/id_rsa user@server:~/
Answers
B.
rsync ~ /.ssh/ user@server:~/
B.
rsync ~ /.ssh/ user@server:~/
Answers
C.
ssh-add user server
C.
ssh-add user server
Answers
D.
ssh-copy-id user@server
D.
ssh-copy-id user@server
Answers
Suggested answer: D

Explanation:

The command ssh-copy-id user@server will allow the user to upload the public key to a remote server and enable passwordless login. The ssh-copy-id command is a tool for copying the public key to a remote server and appending it to the authorized_keys file, which is used for public key authentication. The command will also set the appropriate permissions on the remote server to ensure the security of the key. The command ssh-copy-id user@server will copy the public key of the user to the server and allow the user to log in without a password. This is the correct command to use for this task. The other options are incorrect because they either do not copy the public key (scp, rsync, or ssh-add) or do not use the correct syntax (scp ~/.ssh/id_rsa user@server:~/ instead of scp ~/.ssh/id_rsa.pub user@server:~/ or rsync ~ /.ssh/ user@server:~/ instead of rsync ~/.ssh/id_rsa.pub user@server:~/). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 13: Managing Network Services, page 410.

A Linux administrator created a new file system. Which of the following files must be updated to ensure the filesystem mounts at boot time?

A.
/etc/sysctl
A.
/etc/sysctl
Answers
B.
/etc/filesystems
B.
/etc/filesystems
Answers
C.
/etc/fstab
C.
/etc/fstab
Answers
D.
/etc/nfsmount.conf
D.
/etc/nfsmount.conf
Answers
Suggested answer: C

Explanation:

The file that must be updated to ensure the filesystem mounts at boot time is /etc/fstab. This file contains information about the filesystems that are mounted automatically by the mount -a command, which is usually invoked during the system startup. The /etc/fstab file has six fields for each filesystem: device name, mount point, filesystem type, mount options, dump frequency, and pass number. To add a new filesystem to the /etc/fstab file, you need to specify these fields correctly and make sure the mount point directory exists.

The other options are not correct files for controlling persistent mount points of filesystems. The /etc/sysctl file is used to configure kernel parameters at runtime. The /etc/filesystems file is used to specify the order of filesystem types used by mount when no filesystem type is given. The /etc/nfsmount.conf file is used to set options for mounting NFS filesystems. Reference: Persistently mounting file systems; fstab(5) - Linux manual page

A Linux administrator is troubleshooting a memory-related issue. Based on the output of the commands:

Which of the following commands would address the issue?

A.
top -p 8321
A.
top -p 8321
Answers
B.
kill -9 8321
B.
kill -9 8321
Answers
C.
renice -10 8321
C.
renice -10 8321
Answers
D.
free 8321
D.
free 8321
Answers
Suggested answer: B

Explanation:

The command that would address the memory-related issue is kill -9 8321. This command will send a SIGKILL signal to the process with the PID 8321, which is the mysqld process that is using 99.7% of the available memory according to the top output. The SIGKILL signal will terminate the process immediately and free up the memory it was using. However, this command should be used with caution as it may cause data loss or corruption if the process was performing some critical operations.

The other options are not correct commands for addressing the memory-related issue. The top -p 8321 command will only display information about the process with the PID 8321, but will not kill it or reduce its memory usage. The renice -10 8321 command will change the priority (niceness) of the process with the PID 8321 to -10, which means it will have a higher scheduling priority, but this will not affect its memory consumption. The free 8321 command is invalid because free does not take a PID as an argument; free only displays information about the total, used, and free memory in the system. Reference: How to troubleshoot Linux server memory issues; kill(1) - Linux manual page

A systems administrator made some unapproved changes prior to leaving the company. The newly hired administrator has been tasked with revealing the system to a compliant state. Which of the following commands will list and remove the correspondent packages?

A.
dnf list and dnf remove last
A.
dnf list and dnf remove last
Answers
B.
dnf remove and dnf check
B.
dnf remove and dnf check
Answers
C.
dnf info and dnf upgrade
C.
dnf info and dnf upgrade
Answers
D.
dnf history and dnf history undo last
D.
dnf history and dnf history undo last
Answers
Suggested answer: D

Explanation:

The commands that will list and remove the corresponding packages are dnf history and dnf history undo last. The dnf history command will display a list of all transactions performed by dnf, such as installing, updating, or removing packages. Each transaction has a unique ID, a date and time, an action, and a number of altered packages. The dnf history undo last command will undo the last transaction performed by dnf, meaning that it will reverse all package changes made by that transaction. For example, if the last transaction installed some packages, dnf history undo last will remove them.

The other options are not correct commands for listing and removing corresponding packages. The dnf list command will display a list of available packages in enabled repositories, but not the packages installed by dnf transactions. The dnf remove command will remove specified packages from the system, but not all packages from a specific transaction. The dnf info command will display detailed information about specified packages, but not about dnf transactions. The dnf upgrade command will upgrade all installed packages to their latest versions, but not undo any package changes. Reference: Handling package management history; dnf(8) - Linux manual page

An administrator transferred a key for SSH authentication to a home directory on a remote server.

The key file was moved to .ssh/authorized_keys location in order to establish SSH connection without a password. However, the SSH command still asked for the password. Given the following output:

Which of the following commands would resolve the issue?

A.
restorecon .ssh/authorized_keys
A.
restorecon .ssh/authorized_keys
Answers
B.
ssh_keygen -t rsa -o .ssh/authorized_keys
B.
ssh_keygen -t rsa -o .ssh/authorized_keys
Answers
C.
chown root:root .ssh/authorized_keys
C.
chown root:root .ssh/authorized_keys
Answers
D.
chmod 600 .ssh/authorized_keys
D.
chmod 600 .ssh/authorized_keys
Answers
Suggested answer: D

Explanation:

The command that would resolve the issue is chmod 600 .ssh/authorized_keys. This command will change the permissions of the .ssh/authorized_keys file to 600, which means that only the owner of the file can read and write it. This is necessary for SSH key authentication to work properly, as SSH will refuse to use a key file that is accessible by other users or groups for security reasons. The output of ls -l shows that currently the .ssh/authorized_keys file has permissions of 664, which means that both the owner and group can read and write it, and others can read it.

The other options are not correct commands for resolving the issue. The restorecon .ssh/authorized_keys command will restore the default SELinux security context for the .ssh/authorized_keys file, but this will not change its permissions or ownership. The ssh_keygen -t rsa -o .ssh/authorized_keys command is invalid because ssh_keygen is not a valid command (the correct command is ssh-keygen), and the -o option is used to specify a new output format for the key file, not the output file name. The chown root:root .ssh/authorized_keys command will change the owner and group of the .ssh/authorized_keys file to root, but this will not change its permissions or make it accessible by the user who wants to log in with SSH key authentication. Reference: How to Use Public Key Authentication with SSH; chmod(1) - Linux manual page

A cloud engineer needs to remove all dangling images and delete all the images that do not have an associated container. Which of the following commands will help to accomplish this task?

A.
docker images prune -a
A.
docker images prune -a
Answers
B.
docker push images -a
B.
docker push images -a
Answers
C.
docker rmi -a images
C.
docker rmi -a images
Answers
D.
docker images rmi --all
D.
docker images rmi --all
Answers
Suggested answer: A

Explanation:

The command docker images prune -a will help to remove all dangling images and delete all the images that do not have an associated container. The docker command is a tool for managing Docker containers and images. The images subcommand operates on images. The prune option removes unused images. The -a option removes all images, not just dangling ones. A dangling image is an image that is not tagged and is not referenced by any container. This command will accomplish the task of cleaning up the unused images. The other options are incorrect because they either do not exist (docker push images -a or docker images rmi --all) or do not remove images (docker rmi -a images only removes images that match the name or ID of "images"). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 19: Managing Cloud and Virtualization Technologies, page 567.

A Linux system is failing to boot with the following error:

Which of the following actions will resolve this issue? (Choose two.)

A.
Execute grub-install --root-directory=/mnt and reboot.
A.
Execute grub-install --root-directory=/mnt and reboot.
Answers
B.
Execute grub-install /dev/sdX and reboot.
B.
Execute grub-install /dev/sdX and reboot.
Answers
C.
Interrupt the boot process in the GRUB menu and add rescue to the kernel line.
C.
Interrupt the boot process in the GRUB menu and add rescue to the kernel line.
Answers
D.
Fix the partition modifying /etc/default/grub and reboot.
D.
Fix the partition modifying /etc/default/grub and reboot.
Answers
E.
Interrupt the boot process in the GRUB menu and add single to the kernel line.
E.
Interrupt the boot process in the GRUB menu and add single to the kernel line.
Answers
F.
Boot the system on a LiveCD/ISO.
F.
Boot the system on a LiveCD/ISO.
Answers
Suggested answer: B, F

Explanation:

The administrator should do the following two actions to resolve the issue:

Boot the system on a LiveCD/ISO. This is necessary to access the system and repair the boot loader. A LiveCD/ISO is a bootable media that contains a Linux distribution that can run without installation. The administrator can boot the system from the LiveCD/ISO and mount the root partition of the system to a temporary directory, such as /mnt.

Execute grub-install /dev/sdX and reboot. This will reinstall the GRUB boot loader to the disk device, where sdX is the device name of the disk, such as sda or sdb. The GRUB boot loader is a program that runs when the system is powered on and allows the user to choose which operating system or kernel to boot. The issue is caused by a corrupted or missing GRUB boot loader, which prevents the system from booting. The command grub-install will restore the GRUB boot loader and fix the issue.

The other options are incorrect because they either do not fix the boot loader (interrupt the boot process in the GRUB menu or fix the partition modifying /etc/default/grub) or do not use the correct syntax (grub-install --root-directory=/mnt instead of grub-install /dev/sdX or rescue or single instead of recovery in the GRUB menu). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 8: Managing the Linux Boot Process, pages 265-266.

A Linux administrator needs to create an image named sda.img from the sda disk and store it in the /tmp directory. Which of the following commands should be used to accomplish this task?

A.
dd of=/dev/sda if=/tmp/sda.img
A.
dd of=/dev/sda if=/tmp/sda.img
Answers
B.
dd if=/dev/sda of=/tmp/sda.img
B.
dd if=/dev/sda of=/tmp/sda.img
Answers
C.
dd --if=/dev/sda --of=/tmp/sda.img
C.
dd --if=/dev/sda --of=/tmp/sda.img
Answers
D.
dd --of=/dev/sda --if=/tmp/sda.img
D.
dd --of=/dev/sda --if=/tmp/sda.img
Answers
Suggested answer: B

Explanation:

The command dd if=/dev/sda of=/tmp/sda.img should be used to create an image named sda.img from the sda disk and store it in the /tmp directory. The dd command is a tool for copying and converting data on Linux systems. The if option specifies the input file or device, in this case /dev/sda, which is the disk device. The of option specifies the output file or device, in this case /tmp/sda.img, which is the image file. The command dd if=/dev/sda of=/tmp/sda.img will copy the entire disk data from /dev/sda to /tmp/sda.img and create an image file. This is the correct command to use to accomplish the task. The other options are incorrect because they either use the wrong options (--if or --of instead of if or of) or swap the input and output (dd of=/dev/sda if=/tmp/sda.img or dd --of=/dev/sda --if=/tmp/sda.img). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 10: Managing Storage, page 323.

A Linux administrator is creating a primary partition on the replacement hard drive for an application server. Which of the following commands should the administrator issue to verify the device name of this partition?

A.
sudo fdisk /dev/sda
A.
sudo fdisk /dev/sda
Answers
B.
sudo fdisk -s /dev/sda
B.
sudo fdisk -s /dev/sda
Answers
C.
sudo fdisk -l
C.
sudo fdisk -l
Answers
D.
sudo fdisk -h
D.
sudo fdisk -h
Answers
Suggested answer: C

Explanation:

The command sudo fdisk -l should be issued to verify the device name of the partition.

The sudo command allows the administrator to run commands as the superuser or another user.

The fdisk command is a tool for manipulating disk partitions on Linux systems. The -l option lists the partitions on all disks or a specific disk. The command sudo fdisk -l will show the device names, sizes, types, and other information of the partitions on all disks. The administrator can identify the device name of the partition by looking at the output. This is the correct command to use to accomplish the task. The other options are incorrect because they either do not list the partitions (sudo fdisk /dev/sda or sudo fdisk -h) or do not exist (sudo fdisk -s /dev/sda). Reference: CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 10: Managing Storage, page 317.

Total 371 questions
Go to page: of 38