Practice Free XK0-005 Exam Online Questions
A Linux administrator is configuring a two-node cluster and needs to be able to connect the nodes to each other using SSH keys from the root account.
Which of the following commands will accomplish this task?
- A . [root@nodea ssh ―i ~/. ssh/±d rsa root@nodeb
- B . [root@nodea scp -i. ssh/id rsa root@nodeb
- C . [root@nodea ssh―copy-id ―i .ssh/id rsa root@nodeb
- D . [root@nodea # ssh add -c ~/. ssh/id rsa root@nodeb
- E . [root@nodea # ssh add -c ~/. ssh/id rsa root@nodeb
C
Explanation:
The ssh-copy-id command is used to copy a public SSH key from a local machine to a remote server and add it to the authorized_keys file, which allows passwordless authentication between the machines. The administrator can use this command to copy the root user’s public key from nodea to nodeb, and vice versa, to enable SSH access between the nodes without entering a password every time. For example: [root@nodea ssh-copy-id -i ~/.ssh/id_rsa root@nodeb]. The ssh command is used to initiate an SSH connection to a remote server, but it does not copy any keys. The scp command is used to copy files securely between machines using SSH, but it does not add any keys to the authorized_keys file. The ssh-add command is used to add private keys to the SSH agent, which manages them for SSH authentication, but it does not copy any keys to a remote server.
A systems administrator is checking the system logs. The administrator wants to look at the last 20 lines of a log.
Which of the following will execute the command?
- A . tail -v 20
- B . tail -n 20
- C . tail -c 20
- D . tail -l 20
B
Explanation:
The command tail -n 20 will display the last 20 lines of a file. The -n option specifies the number of lines to show. This is the correct command to execute the task. The other options are incorrect because they either use the wrong options (-v, -c, or -l) or have the wrong arguments (20 instead of 20 filename). CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 11: Managing Files and Directories, page 352.
A systems administrator created a user cron to run a scheduled database backup cronjob on the server at 1 a.m. every day.
The following is the cronjob syntax:
0 1 * * * /bin/sh backup.sh
The backups, however, are not being created.
When checking the crontab file, the administrator sees the following error:
/var/spool/cron/crontab/cron: Permission denied
Which of the following will permit the cronjob to execute?
- A . Creating the file cron.allow and adding user cron to it
- B . Giving cron ownership of the file /usr/bin/crontab
- C . Running sudo cron restart to activate the cronjob
- D . Running sudo crontab -u cron -e to edit the file with sudo
A
Explanation:
The error indicates that the cron user does not have permission to run the cronjob. Creating a cron.allow file and adding the user cron to it will allow that user to run cronjobs. The cron.allow file is a security feature that controls which users are allowed to use cron.
The MySQL database process that was running on a Linux server suddenly stopped, and the process was killed.
Which of the following commands can help identify whether this issue was produced by the OOM killer?
- A . grep /proc/oom_score
- B . grep -ir "out of memory" /var/log
- C . cat /var/run/initramfs/overlayroot.log | grep "out of memory"
- D . cat /sys/block/loop0/events
B
Explanation:
The grep -ir "out of memory" /var/log command searches through log files in /var/log for any instances of "out of memory" errors, which indicate that the oom-killer terminated processes due to insufficient memory. This is the quickest way to determine if the oom-killer caused the MySQL process to be killed.
The MySQL database process that was running on a Linux server suddenly stopped, and the process was killed.
Which of the following commands can help identify whether this issue was produced by the OOM killer?
- A . grep /proc/oom_score
- B . grep -ir "out of memory" /var/log
- C . cat /var/run/initramfs/overlayroot.log | grep "out of memory"
- D . cat /sys/block/loop0/events
B
Explanation:
The grep -ir "out of memory" /var/log command searches through log files in /var/log for any instances of "out of memory" errors, which indicate that the oom-killer terminated processes due to insufficient memory. This is the quickest way to determine if the oom-killer caused the MySQL process to be killed.
A systems administrator pressed Ctrl+Z after starting a program using the command line, and the shell prompt was presented.
In order to go back to the program, which of the following commands can the administrator use?
- A . fg
- B . su
- C . bg
- D . ed
A
Explanation:
Ctrl+Z suspended the process, and "fg" will bring it back into the foreground of the shell
A Comprehensive and To go back to a program that was suspended by pressing Ctrl+Z in the command line, the command that can be used is fg. The fg command stands for foreground, and it resumes the job that is next in the queue and brings it to the foreground. Alternatively, if there are more than one suspended jobs, fg can be followed by a job number to resume a specific job. The other commands are incorrect because they either do not resume a suspended job, or they have different functions such as switching user (su), pushing a job to the background (bg), or editing a file (ed). CompTIA Linux+ Study Guide, Fourth Edition, page 181-182.
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
- B . ssh_keygen -t rsa -o .ssh/authorized_keys
- C . chown root:root .ssh/authorized_keys
- D . chmod 600 .ssh/authorized_keys
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. : How to Use Public Key Authentication with SSH; chmod(1) – Linux manual page
A systems technician is configuring an application server to accept packets from a trusted source with the IP address 192.168.10.22.
Which of the following commands will allow communication between the two servers?
- A . iptables -L -s 192.168.10.22 -j ACCEPT
- B . iptables -D INPUT -s 192.168.10.22 -j ACCEPT
- C . iptables -A INPUT -s 192.168.10.22 -j ACCEPT
- D . iptables -A OUTPUT -S 192.168.10.22 -j ACCEPT
C
Explanation:
The iptables command is used to configure firewall rules in Linux.
To allow packets from a specific source (192.168.10.22) to the server, we must append a rule to the INPUT chain:
iptables -A INPUT -s 192.168.10.22 -j ACCEPT
Explanation of the command:
-A INPUT → Appends a rule to the INPUT chain (incoming traffic).
-s 192.168.10.22 → Specifies the source IP address.
-j ACCEPT → Accepts the packet and allows communication.
Why the other options are incorrect?
A Linux administrator needs to expand a volume group using a new disk.
Which of the following options presents the correct sequence of commands to accomplish the task?
- A . partprobevgcreatelvextend
- B . lvcreatefdiskpartprobe
- C . fdiskpartprobemkfs
- D . fdiskpvcreatevgextend
D
Explanation:
The correct sequence of commands to expand a volume group using a new disk is fdisk, pvcreate, vgextend. The fdisk command can be used to create a partition on the new disk with the type 8e (Linux LVM). The pvcreate command can be used to initialize the partition as a physical volume for LVM. The vgextend command can be used to add the physical volume to an existing volume group. The partprobe command can be used to inform the kernel about partition table changes, but it is not necessary in this case. The vgcreate command can be used to create a new volume group, not expand an existing one. The lvextend command can be used to extend a logical volume, not a volume group. The lvcreate command can be used to create a new logical volume, not expand a volume group. The mkfs command can be used to create a filesystem on a partition or a logical volume, not expand a volume group. CompTIA Linux+ (XK0-005) Certification Study Guide, Chapter 14: Managing Disk Storage, pages 462-463.
Which of the following best describes JSON?
- A . A programming language that developers use to build dynamic websites
- B . An open-source platform that facilitates the creation and administration of isolated environments
- C . A file format for exchanging information or data between systems
- D . A software-based technique that allows a computer to simulate one or more machines so they appear to be real
C
Explanation:
JSON (JavaScript Object Notation) is a lightweight, human-readable, and widely used data-interchange format used in APIs, config files, and infrastructure tools (like Ansible, Terraform, etc.). It is not a programming language (A), not a virtualization/container platform (B or D).
Reference: CompTIA Linux+ XK0-005 Study Guide, Domain 2.4 C Automation and Configuration
“JSON is a text-based format used for structured data exchange and configuration in automation tools.”