LINUX · Configuration · 8 min

Change one configuration setting

Replace an exact setting while preserving a similarly named one.

Not completed

Your task

Change only mode=debug to mode=production in app.conf. Preserve debug_mode=keep and the comment.

What you’re aiming for

  • app.conf has mode=production.
  • debug_mode=keep and the comment are unchanged.

1. Prepare your practice folder

Use a Linux terminal, such as Ubuntu or WSL on Windows. These examples use Linux file permissions. In WSL, create your practice folder in your Linux home directory (~).

Create a new, empty folder for this exercise. If that name already exists, choose another new name. Continue only after you’re inside the new folder.

NEW PRACTICE FOLDER
mkdir opsrung-linux-update-config-line && cd opsrung-linux-update-config-line

Run these setup commands in that folder:

SETUP — RUN ONCE
printf '%s\n' '# practice configuration
mode=debug
debug_mode=keep' > app.conf

2. Try the task

Work toward the goal above. Start by inspecting the files or resources, then use a hint if you need one.

Hint 1

An unanchored substitution may alter the wrong setting.

Hint 2

^ and $ anchor an entire line.

Hint 3

Use sed with an exact mode=debug match.

3. Review your result

Use these commands to look at your result and compare it with the goals. The website does not run or verify them.

REVIEW IN YOUR TERMINAL
cat app.conf

What you should see

  • app.conf has mode=production.
  • debug_mode=keep and the comment are unchanged.

If your result differs: Compare the actual output with each goal. Keep your work inside this exercise’s folder and use only its named resources.

Compare with one possible solution
ONE POSSIBLE SOLUTION
sed -i 's/^mode=debug$/mode=production/' app.conf

Other approaches are fine if you reach the same goal. Opening this solution does not mark the exercise complete.

Finished this exercise?

You decide when you’re done. Your choice is saved in this browser, and you can change it later.