CompTIA certification · Exam XK0-006

XK0-006 Mock Exam

CompTIA Linux+ V8

Free XK0-006 questions on Scripting, Containers, and Automation, each with the answer and an explanation.

20 questions · 21 minutes · free, no sign-up

Scripting, Containers, and Automation questions

1–1 of 1 free
Question 1 Choose 1
A systems administrator is writing a script to analyze the number of files in the directory /opt/application /home/. Which of the following commands should the administrator use in conjunction with ls -l | to count the files?
Show answerHide answer

Correct answer: D wc -l

Explanation

Explanation

The administrator wants to count the number of files listed by:

ls -l

To count lines of output (each file typically appears on one line), the correct command is:

ls -l | wc -l

What wc -l does:

wc = word count utility
-l = counts lines

Each line corresponds to one listed entry, giving the total file count.

❌ Why the Other Options Are Incorrect

❌ less
Pager used to scroll output.
Does not count anything.

❌ tail -f
Continuously monitors file updates.
Used for logs, not counting lines.

❌ tr -c
Translates or deletes characters.
Not used for counting entries.

🧠 Linux+ Exam Tip

Common pipeline pattern:

Goal Command
Count files/output lines wc -l βœ…
Filter text grep
Sort output sort
Remove duplicates uniq

⚠️ Exam note:
ls -l includes a β€œtotal” line, so precise counting often uses:

ls -1 | wc -l

But for this question, wc -l is the intended answer.

That's the last free question in Scripting, Containers, and Automation

You've seen the free 30% (1 of 1 questions). Full access unlocks every question and full-length XK0-006 mock exams (87 questions, 90 minutes), a different mock on every attempt.

Unlock full mock exam
Full mock exam

Sit the XK0-006 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real XK0-006 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full XK0-006 mock exam
  • 87questions per mock
  • 90 mintime limit
  • 150questions in the bank
  • Newmock on every attempt