CHAPTER 03 30 MIN READ INTERMEDIATE

Logging and Syslog Analysis: rsyslog, journald & Key Log Files

Logs are usually the first place an investigation turns, and Linux hosts often run two logging systems side by side rather than one. This chapter covers where that evidence actually lives, how to read it, and what its absence tells you.

syslog journald auth log log analysis

Logging Architecture: syslog vs journald

Most Linux distributions log through one or both of two systems. Knowing which is active on a host determines whether you go looking for flat files or reach for a query tool instead.

SystemStorageNotes
rsyslog / syslogPlain-text files under /var/log/The traditional approach, still widely used and readable with any text tool
systemd-journaldStructured binary journalNot a flat text file, queried with a dedicated tool rather than grepped directly

Many distributions run both side by side. journald often forwards entries to rsyslog, which is what keeps the traditional flat-log files under /var/log/ populated even on a system that logs natively into the journal first.

Key Log Files

Where a given category of event lands depends on which distribution family the host belongs to. Debian-family and RedHat-family systems use different filenames for the same purpose.

FilePurpose
/var/log/auth.logDebian/Ubuntu-family authentication events (logins, sudo, SSH)
/var/log/secureThe RedHat/CentOS-family equivalent, same purpose, different name
/var/log/syslogGeneral system activity on Debian/Ubuntu-family hosts
/var/log/messagesThe RedHat/CentOS-family equivalent of general system activity
/var/log/audit/audit.logPresent only when auditd is configured, detailed system call and file-access auditing
/var/log/cronScheduled task activity, on some distributions mixed into the general system log instead
Note: exact paths vary by distribution. Confirming which logging setup is in play, Debian-family or RedHat-family, rsyslog or journald or both, is a normal first step in any investigation, not something to assume.

Reading Authentication Events

Exact log line formatting varies by distribution and daemon version, so this is about what to look for conceptually rather than a specific string to grep for.

  • Repeated failed SSH login attempts: a burst against one account, or many accounts from one source, points toward a brute-force attempt.
  • A successful login right after a burst of failures: often the strongest single signal in an auth log, a credential-guessing attempt that landed.
  • sudo invocations tied to a specific account and command: shows exactly who escalated privilege and what they ran with it.
  • New user or group creation events: legitimate during provisioning, worth scrutiny anywhere else, especially outside a known change window.

Querying journald

journalctl is the standard tool for reading the structured journal. It can filter by systemd unit, by time range, and by priority level, which is often faster than grepping through flat files for the same information.

Persistence depends on configuration: whether the journal survives a reboot is a configuration choice, not a guarantee. A volatile, memory-only journal loses its history at every reboot, which matters a great deal to an investigator trying to reconstruct what happened before the current boot.

Log Tampering and Gaps

Clearing or truncating logs is a real, well-documented technique attackers use to cover their tracks. A gap or discontinuity in log timestamps and sequence numbers is itself a forensic tell, worth flagging even without knowing exactly what content was removed.

Being able to read logs accurately is the foundation the next three chapters build on:

  • Persistence Mechanisms: many persistence techniques leave a log trace at the moment they are installed.
  • Process and Network Internals: correlating live process and connection state against what the logs already showed.
  • Shell Tradecraft and Detection: recognizing command-line activity that logging alone may only partially capture.

Key Takeaways

  • Linux logs through rsyslog (plain-text files), systemd-journald (structured binary journal), or often both at once, with journald commonly forwarding to rsyslog.
  • Key log locations split by distribution family: auth.log/syslog on Debian-family hosts, secure/messages on RedHat-family hosts.
  • auditd, when configured, adds detailed system call and file-access auditing in /var/log/audit/audit.log.
  • Auth log review centers on failed login bursts, a success following a burst, sudo activity, and new account creation.
  • journalctl filters the structured journal by unit, time range, and priority, but journal persistence across reboots depends on configuration.
  • Cleared logs and gaps in timestamps or sequence numbers are themselves forensic evidence of tampering, detectable even without recovering what was removed.

Knowledge Check

Click an answer to reveal the explanation.

On a RedHat/CentOS-family host, which file serves the same purpose as /var/log/auth.log on Debian/Ubuntu?

Correct answer: B. /var/log/secure is the RedHat/CentOS-family equivalent of auth.log, same authentication-event purpose, different filename.

What is journalctl primarily used for?

Correct answer: B. journalctl is the standard tool for reading journald's structured binary journal, and it supports filtering by unit, time range, and priority level.

An investigator notices a discontinuity in log sequence numbers with no content explaining the missing entries. Why does this matter even without recovering what was deleted?

Correct answer: B. Clearing or truncating logs is a documented anti-forensic technique, and a gap in timestamps or sequence numbers is itself evidence worth flagging, independent of recovering the removed content.