Linux Labs

First steps / Stage 9 of 15

Text and editors

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 8 · on a machine · 4 min

No errors?

What you will learn

  • Read the start, the end and the new lines of a log without paging through the whole file.
  • Find and count lines with grep without taking empty output to mean "nothing there".
  • Edit a file in Vim and check what reached the disk outside the editor.

The report service restarted twice overnight. The on-call engineer checked its log and wrote: "No errors, grep error found nothing."

Exercise · look

Repeat the on-call check

In ~/text-lab, run the two commands below: the on-call engineer's search and a look at the last five lines of the log.

Sign in and start The machine is available after signing in
Check yourself 1 question

Why did grep error find nothing, even though the log has an error?

  • grep checks every line to the end of the file: grep listening service.log finds lines both at the start of the log and at the end.

  • Nothing writes to this log any more, and tail has already shown the error in it: grep reads the same whole file.

  • Without read access grep would print Permission denied. The file is yours — check ls -l service.log.

The log says ERROR in capitals, and the on-call engineer searched for error in lowercase.

Ubuntu 24.04
Loading…