Courseiva
System ManagementhardMultiple ChoiceObjective-mapped

XK0-006 System Management Practice Question

A technician needs to replace all occurrences of '192.168.1.' with '10.0.0.' in the file /etc/network/interfaces and save the changes. Which command accomplishes this?

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

sed -i 's/192\.168\.1/10.0.0/g' /etc/network/interfaces

Uses `sed -i 's/192\.168\.1/10.0.0/g' /etc/network/interfaces`. The backslashes escape the dots, matching literal periods. The `-i` flag edits the file in-place. This replaces '192.168.1' (without the trailing dot) with '10.0.0', leaving the trailing dot intact, resulting in '10.0.0.' as required. Options A and C have unescaped dots, which match any character, making them imprecise. Option D also has unescaped dots and would incorrectly replace any character in place of the dots. Additionally, option C redirects to the same file, which can truncate it before reading completes.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • awk '{gsub(/192.168.1./,"10.0.0.");print}' /etc/network/interfaces > tmp && mv tmp /etc/network/interfaces

    Why it's wrong here

    Uses awk with unescaped dots, matching any character; also creates a temporary file but the pattern is not exact.

  • sed -i 's/192\.168\.1/10.0.0/g' /etc/network/interfaces

    Why this is correct

    Correct: Escaped dots, in-place substitution, replaces only the first three octets, leaving the trailing dot.

  • sed 's/192.168.1./10.0.0./g' /etc/network/interfaces > /etc/network/interfaces

    Why it's wrong here

    Unescaped dots and dangerous redirect to the same file; the shell truncates the file before sed reads it.

  • sed -i 's/192.168.1./10.0.0./g' /etc/network/interfaces

    Why it's wrong here

    Unescaped dots in the pattern will match any character (including letters or digits) instead of literal periods, potentially corrupting the file.

About these practice questions

One of 979 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 →

How Courseiva writes practice questions · Editorial policy

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.