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
- A log is a record of events, made of entries; security questions are answered from logs.
- journalctl reads the journal; filter by service, time and priority.
- logrotate rotates, compresses and removes logs so a disk does not fill.
- Synchronized clocks (NTP) keep logs from different machines comparable.
- Updating is fetch metadata, then upgrade; security upgrades can be automatic.
Sources
- NIST SP 800-92: Guide to Computer Security Log Management
- systemd documentation: journalctl(1)
- logrotate(8) manual page (Debian)
- RFC 5905: Network Time Protocol Version 4
- Debian Reference, chapter 2: Debian package management
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.
- Read your Linux logs with journalctl: You filter the journal by service, priority and boot, the skill this unit teaches.
- Installing software and keeping Linux patched with apt: You update, upgrade, install and remove software with apt, the patching habit in practice.
- Stop a runaway log from filling the disk with logrotate (and measure what create vs copytruncate really cost): You watch a runaway log fill a small disk and fix it, and see what a full disk costs a defender.
- Keep your clock honest: NTP, UTC, and why a wrong clock breaks security: You prove a clock is synchronised and see what a wrong clock breaks.
Knowledge check
- 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).
- 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.
- 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
- Operating systems and the command line
- Read your Linux logs with journalctl
- Installing software and keeping Linux patched with apt
- Stop a runaway log from filling the disk with logrotate (and measure what create vs copytruncate really cost)
- Keep your clock honest: NTP, UTC, and why a wrong clock breaks security
- All classes
- Free cyber labs