>_ IzzyLab

Hands-on task

This task is step 19 of the course “Linux: everyday tasks”

Turn off debug in every service

easy~3 min

Someone forgot to switch the shop server out of debug mode: every .ini file in /etc/shop/ has the line log_level=debug. Replace it with log_level=info in all the .ini files, and keep the original versions next to them with the .orig extension (for example, cart.ini.orig). Don't touch the README file in the same directory.

What you'll practise:
  • sed
  • s/// substitution
  • in-place editing
  • backup copies
  • glob patterns

Topic breakdown

sed is a stream editor: it reads text line by line and applies commands to each line, most often the substitution s/pattern/replacement/. Without extra flags the result goes to standard output and the file stays unchanged. The -i flag writes the changes back to the file, and a suffix after it tells sed to save the original under a new name first — so the edit is easy to roll back. To process many files at once you don't list them by hand: a shell glob pattern expands into the list of matching paths before the command even starts.

What's checked

  1. no log_level=debug left in .ini
  2. log_level=info in all four .ini
  3. .ini.orig copies with the original content sit next to them
  4. README untouched

What it looks like