XK0-006 System Management Practice Question
Which command would a Linux administrator use to locate all files in the /var/log directory that have been modified within the last 7 days?
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
find /var/log -mtime -7
The find command with -mtime -7 finds files modified less than 7 days ago. The other options are either incorrect or not suitable for this task.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
ls -lt /var/log | head -n 7
Why it's wrong here
ls -lt sorts by modification time and head -n 7 returns seven entries, not files modified within seven days, and it also lists directories. It is tempting because the number seven appears in both, but the correct tool is find with -mtime -7.
- ✗
grep -mtime -7 /var/log
Why it's wrong here
grep searches file contents for text patterns; -mtime is not a grep option and would be treated as a pattern or rejected. It is tempting because grep is a familiar search command, but it cannot filter by filesystem timestamps; find with -mtime -7 performs that selection.
- ✗
locate -mtime -7 /var/log
Why it's wrong here
locate queries a prebuilt filename database and has no -mtime predicate, so it cannot filter by modification time. It is tempting because locate is genuinely fast for finding paths by name, and would be the right tool when you only need to match filenames across the filesystem.
- ✓
find /var/log -mtime -7
Why this is correct
The -mtime -7 predicate matches files whose data was modified less than seven days ago, and find recurses through /var/log automatically. This directly satisfies the constraint of locating all files in that directory modified within the last 7 days.
Go deeper
Related to this question
About these practice questions
One of 781 original XK0-006 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.