Question 353 of 522
GNU and Unix CommandshardMultiple ChoiceObjective-mapped

Quick Answer

The correct command sequence is sed -i 's/setting1=default/setting1=production/' /etc/example.conf followed by sed -i '/^include /a\nsetting2=value' /etc/example.conf. This works because the -i flag tells sed to edit the file in place without creating a backup, while the substitution command (s///) replaces the existing setting, and the append command (a\) inserts a new line after the matching pattern. On the LPIC-1 exam, this tests your understanding of sed’s in-place editing and its address commands, often appearing in scenario-based questions where you must modify configuration files without leaving backup copies. A common trap is forgetting that -i alone does not create a backup, but -i.bak would; also, the append command requires a backslash before the new line content. Memory tip: think “-i for in-place, no backup backup” and remember that sed’s a command appends after, not before, the matched line.

LPIC-1 GNU and Unix Commands Practice Question

This LPIC-1 practice question tests your understanding of gnu and unix commands. This is a configuration task: choose the command set that satisfies every stated requirement. Small differences — like 'secret' vs 'password' or 'transport input ssh' vs 'all' — change whether the answer is correct. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Network Topology
-rw-rrRefer to the exhibit.# ls -l# cat /etc/example.conf# Configuration filesetting1=default# Include other configinclude /etc/example.d/*.conf

Refer to the exhibit. An administrator needs to edit /etc/example.conf to change setting1 to 'production' and add a new line 'setting2=value' after the include line. The file must be edited in place without creating a backup. Which command sequence achieves this?

Clue words in this question

Noticing these words before you look at the options changes how you read each choice.

  • Clue: "which command"

    Why it matters: Tests specific CLI syntax. Recall the exact command and its required context — near-synonyms and partial matches are common distractors.

Question 1hardmultiple choice
Full question →
Network Topology
-rw-rrRefer to the exhibit.# ls -l# cat /etc/example.conf# Configuration filesetting1=default# Include other configinclude /etc/example.d/*.conf

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/setting1=default/setting1=production/' /etc/example.conf; sed -i '/^include /a\nsetting2=value' /etc/example.conf

Option A is correct because the first sed command uses the -i flag to edit the file in place without a backup, and the substitution 's/setting1=default/setting1=production/' changes the existing setting. The second sed command uses the 'a' (append) command after the line matching '^include ' to add the new line 'setting2=value' after it, also with -i to avoid creating a backup.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

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

  • sed -i 's/setting1=default/setting1=production/' /etc/example.conf; sed -i '/^include /a\nsetting2=value' /etc/example.conf

    Why this is correct

    Correct: -i without argument edits in place; first command changes the setting; second appends after the include line.

    Clue confirmation

    The clue word "which command" in the question point toward this answer.

    Related concept

    Read the scenario before looking for a memorised answer.

  • sed -i 's/setting1=default/setting1=production/' /etc/example.conf; sed -i '/^include /i\nsetting2=value' /etc/example.conf

    Why it's wrong here

    Second command uses i (insert before) instead of a (append after), so setting2 would be inserted before the include line, not after.

  • sed -i.bak 's/setting1=default/setting1=production/' /etc/example.conf; sed -i.bak '/^include /a\nsetting2=value' /etc/example.conf

    Why it's wrong here

    Same as A, creates backup.

  • sed -i.bak 's/setting1=default/setting1=production/' /etc/example.conf; sed -i.bak '/^include /a\nsetting2=value' /etc/example.conf

    Why it's wrong here

    Creates backups, not without backup.

Common exam traps

Common exam trap: answer the scenario, not the keyword

The trap here is that candidates often confuse the 'a' (append) and 'i' (insert) sed commands, or overlook the requirement to avoid backups by choosing options with -i.bak instead of plain -i.

Trap categories for this question

  • Command / output trap

    Second command uses i (insert before) instead of a (append after), so setting2 would be inserted before the include line, not after.

Detailed technical explanation

How to think about this question

The sed -i flag performs in-place editing by writing changes to a temporary file and then renaming it over the original; when a suffix like .bak is provided, the original file is saved with that suffix before renaming. The 'a' command appends text after the matched line, while 'i' inserts before it, and both commands require a backslash-newline sequence to separate the address from the appended text. In real-world scenarios, administrators often use sed for bulk configuration changes across multiple servers, and forgetting the -i flag without a suffix can lead to accidental backups filling disk space.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A practitioner preparing for the LPIC-1 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related LPIC-1 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free LPIC-1 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this LPIC-1 question test?

GNU and Unix Commands — This question tests GNU and Unix Commands — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: sed -i 's/setting1=default/setting1=production/' /etc/example.conf; sed -i '/^include /a\nsetting2=value' /etc/example.conf — Option A is correct because the first sed command uses the -i flag to edit the file in place without a backup, and the substitution 's/setting1=default/setting1=production/' changes the existing setting. The second sed command uses the 'a' (append) command after the line matching '^include ' to add the new line 'setting2=value' after it, also with -i to avoid creating a backup.

What should I do if I get this LPIC-1 question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Are there clue words in this question I should notice?

Yes — watch for: "which command". Tests specific CLI syntax. Recall the exact command and its required context — near-synonyms and partial matches are common distractors.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This LPIC-1 practice question is part of Courseiva's free LPI 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 LPIC-1 exam.