Logs, updates and keeping time

Unit 5 of 5 in Operating systems and the command line.

You will be able to read system logs, keep a machine patched and explain why clocks and log rotation matter.

Lesson

What a log is

NIST defines a log as a record of the events occurring within an organization's systems and networks. A log is made of entries, and each entry describes one event. Many logs, from operating systems, firewalls and security software, hold records that matter for security.

Logs are how you answer the questions that come after something goes wrong: what happened, when, and to which account or machine.

Reading logs on a modern Linux box

On many Linux systems the journal collects log entries, and journalctl prints them. Called with no options it shows the journal contents you are allowed to see, starting with the oldest entry. You narrow it with matches in the form FIELD=VALUE, for example one service's unit name, so you see only what you need.

Reading with filters beats scrolling: choose the service, the time range and the priority, and the noise falls away.

Rotation: logs that never grow forever

A log that grows without limit can fill a disk, and a full disk can stop a system from recording new events at all. logrotate is a tool designed to ease administration of systems that generate many log files. It can automatically rotate, compress, remove and mail log files, handling each daily, weekly, monthly or when a file grows too large.

NIST lists monitoring log rotation and archival among the regular tasks of the people who manage logs.

Time: a wrong clock breaks the story

Events from different machines only line up if their clocks agree. The Network Time Protocol is widely used to synchronize computer clocks across the Internet. NIST advises using time synchronization technologies such as NTP servers wherever possible, so that log sources' clocks stay consistent with each other, and lists checking that each logging host's clock is synced to a common time source as a routine task.

Updates: the quiet defence

On Debian-family systems, updating is two steps. First the system fetches fresh archive metadata from the remote archive. Then an upgrade chooses the candidate version, usually the latest available, for each installed package and installs it. The Debian reference also lists an enhancement package that enables automatic installation of security upgrades. Keeping software current closes known holes before anyone uses them.

Key points

Sources

Lecture

Logging and detection pipelines: A talk on how logs become alerts, the bigger picture behind this unit.

Practice in the labs

Read real logs, patch a system, tame a growing log and check a clock.

Knowledge check

  1. Why can a log that grows without limit be a security problem? Answer: A full disk can stop new events from being recorded. If the disk fills, the system may be unable to record new events, which leaves a blind spot. Rotation exists to prevent that (logrotate(8), NIST SP 800-92).
  2. Two servers log the same attack but their clocks differ by ten minutes. What is the problem? Answer: The logs cannot be ordered against each other without correction. NIST notes sources can be out of sync, so times must be adjusted, and advises NTP to keep clocks consistent across log sources.
  3. What are the two steps of a typical package update on a Debian-family system? Answer: Fetch fresh archive metadata, then upgrade the installed packages. The Debian reference describes an update that fetches archive metadata and an upgrade that installs the candidate (usually latest) versions of packages.

Back to the syllabus or see all classes.

Related