Professor Franklin
Accessibility settings

Preferences are saved in this browser when storage is available.

Getting Started

Chapter 12 · Reading 1 of 3

Linux logs, the journal and shell history

CHFI domains 3, 4, 5, 6

Halyard Creative’s build server, halyard-build, runs Ubuntu. Designers upload finished artwork to it over SSH, and the client downloads from a web folder it serves. The directory listing says final_artwork.zip was last modified at 08:15 on 10 November, four days after the designer says it was sent. Linux keeps several independent records of who signed in and what they did. Each one can confirm or contradict that listing.

Authentication and the system log

On Debian and Ubuntu, authentication events go to /var/log/auth.log. On Red Hat, Fedora and their relatives, they go to /var/log/secure. Both record SSH logins (Accepted publickey or Accepted password), failures, sudo commands with the command line, and account changes. General system messages go to /var/log/syslog or /var/log/messages. These text logs are rotated, often weekly, into numbered and compressed files such as auth.log.1 and auth.log.2.gz, so a collection must include the rotated copies.

Figure 1. Two SSH sessions for the deliver account in auth.logThe server’s clock is UTC and synchronized with NTP.
Nov  6 17:42:03 halyard-build sshd[40102]: Accepted publickey for deliver from 10.20.4.31 port 50112 ssh2: ED25519 SHA256:4mX…
Nov 10 08:14:51 halyard-build sshd[48211]: Accepted publickey for deliver from 10.20.7.88 port 61844 ssh2: ED25519 SHA256:pQ9…
  1. The designer’s MacBook, according to the DHCP records.
  2. An account manager’s laptop.
  3. A different key fingerprint, so a different private key, was used for the second login.

Traditional syslog lines do not include a year or time zone. The examiner takes the year from the file’s context and the zone from the system’s configuration in /etc/timezone or the /etc/localtime link.

The systemd journal

Most current distributions also log to the systemd journal, a structured binary log stored in /var/log/journal/ when persistent storage is configured, or only in memory under /run/log/journal/ when it is not. Each entry carries precise UTC timestamps, the unit, process ID, user ID and boot ID. journalctl reads it, and can read a collected journal directory with journalctl -D <dir>. Useful filters include -u ssh for one unit, --since and --until for a window, _UID= for one user and -o json for export. Journal files have internal checksums and can be checked with journalctl --verify.

Login records

Three binary files record logins. /var/log/wtmp holds logins, logouts and reboots, read with last. /var/log/btmp holds failed logins, read with lastb. /var/log/lastlog holds each account’s most recent login, read with lastlog. Comparing these with auth.log helps detect tampering: an attacker who edits one source often forgets the others.

Shell history and scheduled tasks

Bash records commands in each user’s ~/.bash_history when the shell exits. By default it holds no timestamps. If HISTTIMEFORMAT was set, lines beginning with # and a Unix time precede each command. History can be incomplete: sessions killed abruptly may not write it, commands beginning with a space may be skipped, and users can clear it. The deliver account’s history ends with:

cd /srv/proofs/client-ballard
touch final_artwork.zip
ls -l
  1. touch sets a file’s modification and access times to the current time without changing its content.

Cron jobs live in /etc/crontab, /etc/cron.d/, the /etc/cron.daily family of folders and per-user crontabs in /var/spool/cron/crontabs/. Systemd timers and services live in /etc/systemd/system/ and /usr/lib/systemd/system/. Both are common places for persistence and for routine jobs that change files, which is why the examiner checks them before blaming a person for a timestamp. Nothing scheduled on halyard-build touches the proofs folder.

Figure 2. Linux sources for the delivery
auth.log and journal
deliver logged in from the Mac on 6 Nov 17:42 and from another laptop on 10 Nov 08:14.
wtmp
Matching sessions: 17:42–17:44 on 6 Nov and 08:14–08:16 on 10 Nov.
.bash_history
A touch of final_artwork.zip, undated, written at the end of the most recent session.

On the exam, remember auth.log for Debian-family systems and secure for Red Hat-family systems, last for wtmp and lastb for btmp, and that bash history has no times unless configured to. The next reading, macOS unified logs and user records, examines the designer’s side of the transfer.

auth.log entry

Inspect the three records, then use the evidence to answer the question.

1. Account

deliver

2. Source

10.20.7.88 (account-manager laptop)

3. Time

Nov 10 08:14:51 (server local time, UTC)

Apply the reading

The deliver account’s .bash_history shows a touch command but no times. How could you date it?

Compare your reasoning

Check whether HISTTIMEFORMAT was set, which adds timestamp comment lines. Otherwise, bound it with the history file’s modification time, the session’s login and logout times in auth.log, the journal and wtmp, and the file’s change time (ctime), which records when its metadata was last changed.