CompTIA XK0-005 CompTIA Linux+ Certification Exam Practice Test

Page: 1 / 14
Total 396 questions
Question 1

A Linux engineer needs to get information from the foo.com domain mail servers. Which of the following network tools should the engineer use?



Answer : C

To query Mail Exchange (MX) records for a domain, use dig:

dig mx foo.com

MX records specify which mail servers handle email for a domain.

Why the other options are incorrect?

A . arp mx foo.com Incorrect, arp is used for MAC address resolution, not DNS lookups.

B . nc mx foo.com Incorrect, nc (netcat) is used for networking and port scanning, not DNS queries.

D . route mx foo.com Incorrect, route manages routing tables, not DNS records.


Linux dig Command -- Linux Documentation

Question 2

A Linux engineer is removing a previously created firewall rule. Which of the following commands will help the administrator accomplish this task?



Answer : B

The ufw (Uncomplicated Firewall) delete command is used to remove rules.

If the original rule was ufw deny 80/tcp, it must be deleted with:

ufw delete deny 80/tcp

Why the other options are incorrect?

A . ufw delete 80/tcp Incorrect, because delete requires specifying the action (allow or deny).

C . ufw delete 80/tcp deny Incorrect syntax; deny must come before the port.

D . delete7! Incorrect, this is not a valid ufw command.


UFW Documentation -- Ubuntu

Question 3

An administrator is investigating why a Linux workstation is not resolving a website. The output of dig and nslookup shows that IPv4 resolution is working, but IPv6 resolution fails.

The administrator executes:

nslookup -querytype=AAAA www.comptia.org

Can't find www.comptia.org: No answer

The workstation has a static entry in /etc/hosts:

CopyEdit

104.18.99.101 www.comptia.org

Which of the following is the most likely cause?



Answer : A

The presence of a static entry in /etc/hosts for www.comptia.org forces the system to use this IP address instead of querying DNS.

This prevents proper IPv6 (AAAA) resolution, as /etc/hosts only contains an IPv4 (A) record.

Removing this static entry allows the system to query DNS for both IPv4 and IPv6 records.


Linux /etc/hosts File -- Linux Documentation

Question 4

A Linux engineer receives the following notification from a system:

cp: cannot create regular file '/app/appdata.tar*': No space left on device

The engineer obtains the following output:

[root@host ~]# df -i /app

Filesystem Inodes IUsed IFree Mounted on

/dev/vdb 2048 2048 0 /app

bash

CopyEdit

[root@host ~]# df -h /app

Filesystem Size Used Avail Use% Mounted on

/dev/vdb 2.0G 6.1M 1.9G 1% /app

Which of the following describes the state of the filesystem based on this output?



Answer : B

The error 'No space left on device' usually means either disk space or inodes are exhausted.

Checking the disk space (df -h), we see only 6.1MB is used, meaning there is plenty of free space (1.9GB available).

Checking inodes (df -i), we see all 2048 inodes are used (IUsed = 2048, IFree = 0), meaning no new files can be created even though space is available.

Inodes are metadata structures used to track files. Small files or a large number of directories can exhaust inodes before disk space runs out.

Fixing the Issue:

Remove unnecessary small files to free inodes:

find /app -type f -exec rm -f {} +

Recreate the filesystem with a higher inode count:

bash

CopyEdit

mkfs.ext4 -N 500000 /dev/vdb


Question 5

A DevOps engineer is working on a local copy of a Git repository. The engineer would like to switch from the main branch to the staging branch but notices the staging branch does not exist. Which of the following Git commands should the engineer use to perform this task?



Answer : D

In Git, if a branch does not exist and you need to create and switch to it in one command, use:

git checkout -b

OR

git switch -c

(For newer Git versions, switch is preferred.)

git checkout -b staging

-b creates a new branch.

staging is the new branch name.

This also switches to the new branch immediately.

Why the other options are incorrect?

A . git branch -m st Incorrect, -m is used for renaming a branch, not creating one.

B . git commit -m staging Incorrect, commit -m is used to commit changes with a message, not to create a branch.

C . git status -b staging Incorrect, git status shows the current repository state, but -b is not a valid option for it.


Git Branching -- Git Docs

Question 6

An administrator needs to stop a foreground process in between its execution in a terminal. Which of the following should the administrator use?



Answer : D

Step-by-Step Comprehensive Detailed

Command

Ctrl+C sends a SIGINT (interrupt signal) to the foreground process, stopping its execution.

Why Other Options are Incorrect:

A: Ctrl+D signals the end-of-file (EOF) in a shell but does not stop processes.

B: Ctrl+F moves the cursor forward but does not affect processes.

C: Ctrl+Z suspends the process (sends it to the background) but does not stop it permanently.


CompTIA Linux+ Training Materials, Signal Management

man signal

Question 7

A Linux administrator is creating a directory called CompTIA_doc, and it needs to switch to another location to perform some system-related tasks. Which of the following commands should the administrator use for this task?



Answer : D

Step-by-Step Comprehensive Detailed

Command

mkdir CompTIA_doc creates the directory, and && ensures the cd CompTIA_doc command executes only if the directory creation is successful.

Why Other Options are Incorrect:

A: The & runs commands in the background and does not ensure sequential execution.

B: + is not a valid operator in shell commands.

C: || executes the second command only if the first command fails.


Linux+ Certification Exam Resources

man mkdir, man cd

Page:    1 / 14   
Total 396 questions