Configuration files and directories:
- /etc/systemd/journald.conf
- /etc/systemd/journald.conf.d/*.conf
- /run/systemd/journald.conf.d/*.conf
- /usr/lib/systemd/journald.conf.d/*.conf

Persistent journal files:
- /var/log/journal/<MACHINE_ID>/system.journal
- /var/log/journal/<MACHINE_ID>/user-<UID>.journal
- /var/log/journal/<MACHINE_ID>/*@*.journal (archived)
- /var/log/journal/<MACHINE_ID>/*@*.journal~ (dirty / corrupted)

Volatile journal files (in memory, lost at shutdown):
- /run/log/journal/<MACHINE_ID>/

Network forwarding configuration (if configured):
- /etc/systemd/journal-upload.conf
- /etc/systemd/journal-remote.conf
- /etc/systemd/journal-remote.conf.d/*.conf
- /usr/lib/systemd/journal-remote.conf.d/*.conf

Remote journal files (systemd-journal-remote):
- /var/log/journal/remote/remote-<HOSTNAME>.journal

Overview

The systemd journal is the logging framework of systemd, implemented by the systemd-journald daemon. It is the default logging framework on most modern Linux distributions (Debian, Ubuntu, Red Hat / CentOS / Rocky, Fedora, Arch, SUSE, etc.). journald addresses some of the shortcomings of syslog, notably by storing structured, indexed, and (optionally) cryptographically sealed log entries.

journald collects messages from multiple sources and records the source in the _TRANSPORT field of each entry:

_TRANSPORT Source
driver Internally generated by journald.
syslog Messages received through the syslog socket (/dev/log), i.e. messages emitted with the syslog(3) interface (sshd, sudo, cron, logger, etc.).
journal Messages received through the native journald protocol (sd_journal_* API, systemd-cat, logger --journald, systemd itself, etc.).
stdout Standard output and standard error of services started by systemd.
kernel Kernel messages (kmsg, equivalent to dmesg).
audit Messages from the Linux Audit framework, if the systemd-journald-audit.socket is enabled (not enabled by default on many recent distributions).

journald and syslog often coexist on the same system. rsyslog may, for instance, read messages from the journal (imjournal module), or journald may forward messages to the syslog socket (ForwardToSyslog= option). Some recent distributions (such as Debian 12 and later) no longer install a syslog implementation by default, making the journal the only source of system logs.

journald is enabled by default on all systems using systemd as their init system.

Configuration

journald is configured through the /etc/systemd/journald.conf file, which can be overridden by drop-in files under the journald.conf.d directories:

  • /etc/systemd/journald.conf.d/*.conf
  • /run/systemd/journald.conf.d/*.conf
  • /usr/lib/systemd/journald.conf.d/*.conf

On a live system, the following command can be used to display the full journald config including the drop-in files, if any:

systemd-analyze cat-config systemd/journald.conf

The following options are of particular interest for forensic analysis:

Option Description
Storage= Where the journal is stored:
- volatile: in memory only, under /run/log/journal/. The journal is lost at system shutdown.
- persistent: on disk, under /var/log/journal/ (with a fallback to /run/log/journal/ early in the boot process or if the disk is not writable).
- auto (default on most versions): persistent if the /var/log/journal/ directory exists, volatile otherwise.
- none: all messages are dropped (forwarding to syslog or the console still applies).

The persistent journal is enabled by default on most distributions, but historically not on some (such as Red Hat / CentOS 7, which relied on rsyslog and /var/log/messages).
SplitMode= uid (default): logs of non-system users are stored in dedicated user-<UID>.journal files.
none: all entries are stored in system.journal.
SystemMaxUse=
SystemKeepFree=
SystemMaxFileSize=
SystemMaxFiles=
Size and file count limits for the persistent journal. By default, the journal uses up to 10% of the file system size (capped at 4G), leaves at least 15% free (capped at 4G), and keeps at most 100 journal files (SystemMaxFiles=). When the disk space or file count limits are reached, the archived files are deleted, oldest first, while the active files are kept.
The Runtime* equivalents apply to the volatile journal.
MaxRetentionSec= Maximum time to retain entries. Disabled by default (0), with the retention only bounded by the disk space limits.
MaxFileSec= Maximum time span covered by a single journal file before it is rotated (1month by default).
Compress= Compression of large data objects (XZ, LZ4, or ZSTD depending on the build). Enabled by default.
Seal= Forward Secure Sealing (FSS) of the journal files, effective only if a sealing key was generated with journalctl --setup-keys. Enabled by default, but no key is generated by default.
ReadKMsg= Whether kernel messages (from /dev/kmsg) are collected in the journal. Enabled by default.
ForwardToSyslog=
ForwardToKMsg=
ForwardToConsole=
ForwardToWall=
Forwarding of the messages to the syslog socket, the kernel log buffer, the console, or logged-in users.
LogNamespace= Setting of a systemd unit (not of journald.conf) that runs the processes of the unit in the specified journal namespace (since systemd 245).

A journal namespace is a log stream isolated from the default journal, with its own journald instance (systemd-journald@<NAMESPACE>.service), configuration (/etc/systemd/journald@<NAMESPACE>.conf and the associated drop-in files), and journal files (/var/log/journal/<MACHINE_ID>.<NAMESPACE>/, persistent by default). All the messages of the unit (syslog, native journald protocol, and standard output / error) are logged in the namespace, and are thus not displayed by journalctl by default (the --namespace=<NAMESPACE> or --namespace=* option must be used).

Unusual configuration changes, such as Storage=volatile or Storage=none, a very short MaxRetentionSec=, or a low SystemMaxUse=, may indicate an attempt to limit logging. The modification timestamps of the configuration files should be reviewed accordingly.

Journal files

The persistent journal files are stored in a directory named after the system machine-id (/etc/machine-id), under /var/log/journal/<MACHINE_ID>/:

  • system.journal: the currently active system journal file.

  • user-<UID>.journal: the currently active journal file of the user <UID> (non-system users only, with SplitMode=uid).

  • system@<SEQNUM_ID>-<HEAD_SEQNUM>-<HEAD_REALTIME>.journal / user-<UID>@<SEQNUM_ID>-<HEAD_SEQNUM>-<HEAD_REALTIME>.journal: archived (rotated) journal files. The <HEAD_REALTIME> value is the hex-encoded timestamp (in microseconds since epoch) of the first entry of the file.

  • system@<HEX_VALUES>.journal~ / user-<UID>@<HEX_VALUES>.journal~: journal files that were not properly closed (following a system crash or an unclean shutdown) or that were detected as corrupted by journald. These files are renamed and a new file is started. They usually remain readable and should be included in the analysis.

Journal namespaces (LogNamespace= setting of a systemd unit) are stored in separate directories, named /var/log/journal/<MACHINE_ID>.<NAMESPACE>/, and are not displayed by journalctl without the --namespace option.

Journal files received from remote hosts with systemd-journal-remote are stored by default under /var/log/journal/remote/, in one file per remote host, named remote-<HOSTNAME>.journal. The archived and .journal~ file naming conventions also apply to these files.

The journal files use a binary format (starting with the LPKSHHRH signature), composed of ENTRY, DATA, FIELD, ENTRY_ARRAY, hash table, and TAG objects. Identical field values are deduplicated and stored once in DATA objects, which are referenced by the ENTRY objects. Some log strings may thus not be found with a simple strings / grep search of the files, notably if the DATA object is compressed.

systemd 252 introduced a “compact” journal file format, which is not readable by older versions of journalctl. A recent version of journalctl (or another up-to-date parser) should thus be used to analyze journal files from recent systems.

Integrity and tampering

Journal files are not protected against tampering by default. root can delete journal files or entries, for example with journalctl --rotate --vacuum-time=1s (which deletes all archived journal files) or by directly deleting the files under /var/log/journal/.

Forward Secure Sealing (FSS) can be configured to detect the modification of journal files, by periodically sealing the files with a key that evolves over time (journalctl --setup-keys). The verification key is displayed once at setup and must be stored off-system. The integrity of the journal files can be checked with journalctl --verify [--verify-key=<VERIFICATION_KEY>], which also detects (non-sealed) corrupted files.

The following elements may indicate tampering or log clearing:

  • Missing journal files or time ranges (for example, journalctl --list-boots with a first boot more recent than expected).
  • Gaps in the __SEQNUM values.
  • Recent modification timestamps on the journald configuration files.
  • journalctl --vacuum-* or rm commands in the shell histories or audit logs.

Network forwarding

As with syslog, the journal entries can be sent over the network. On the sending host, systemd-journal-upload.service uses the systemd-journal-upload program to upload the entries. On the receiving host, systemd-journal-remote.service uses the systemd-journal-remote program to receive the entries and store them in journal files. The transfers rely on HTTP(S) (thus over TCP, with optional encryption and authentication of the hosts).

  • The /etc/systemd/journal-upload.conf file configures the sending host, notably the receiving host (URL= option).

  • The /etc/systemd/journal-remote.conf, /etc/systemd/journal-remote.conf.d/*.conf, and /usr/lib/systemd/journal-remote.conf.d/*.conf files configure the receiving host.

These files may not exist if the network features of the journal are not configured. If the system was configured to forward its journal, the remote host may hold a copy of entries that were deleted or altered locally.

Journal entry fields

Each journal entry is a set of FIELD=VALUE pairs. There are three categories of fields:

  • User fields, set by the logging process (and thus attacker-controllable): MESSAGE, MESSAGE_ID, PRIORITY, SYSLOG_IDENTIFIER, SYSLOG_PID, SYSLOG_FACILITY, CODE_FILE, CODE_LINE, CODE_FUNC, etc.

  • Trusted fields, prefixed by a single underscore (_), which are added by journald itself (notably based on the credentials of the socket peer, /proc/<PID>/, and the process cgroup). These fields cannot be set or altered by the logging process.

  • Address fields, prefixed by a double underscore (__), which are computed when reading the journal: __CURSOR, __REALTIME_TIMESTAMP, __MONOTONIC_TIMESTAMP, and __SEQNUM.

Field Description
_SOURCE_REALTIME_TIMESTAMP The time (in microseconds since epoch, UTC) at which the message was emitted by the logging process, when available. More accurate than __REALTIME_TIMESTAMP, the time at which the entry was received by journald.
__REALTIME_TIMESTAMP The time (in microseconds since epoch, UTC) at which the entry was received by journald. Displayed in local time by journalctl by default (--utc to display timestamps in UTC).
__MONOTONIC_TIMESTAMP The time (in microseconds) elapsed since the boot (_BOOT_ID) at the time of reception, not affected by system time changes.
__SEQNUM The sequence number of the entry, increasing monotonically. Gaps or discontinuities may indicate deleted / missing entries.
_MACHINE_ID
_HOSTNAME
The machine-id and the hostname of the system.
_COMM
_EXE
_CMDLINE
The name, executable path, and command line of the logging process.
These fields may be missing if the process exited before journald could retrieve its information.
_SYSTEMD_UNIT
_SYSTEMD_USER_UNIT
_SYSTEMD_SLICE
_SYSTEMD_CGROUP
The systemd unit, user unit, slice, and control group of the logging process.
_SYSTEMD_SESSION
_SYSTEMD_OWNER_UID
The systemd-logind session identifier and the UID of the session owner, for processes started in a user session.
_AUDIT_SESSION
_AUDIT_LOGINUID
The audit session and login user identifier (auid, i.e. the UID of the user that originally logged in, unchanged by su / sudo) of the logging process.
_SYSTEMD_INVOCATION_ID A unique identifier of each execution of a systemd unit.
_TRANSPORT How the entry was received by journald (driver, syslog, journal, stdout, kernel, or audit).
_PID
_UID
_GID
The process, user, and group identifiers of the logging process.
_BOOT_ID A unique identifier of the boot, randomly generated at each system startup.
SYSLOG_FACILITY The syslog facility of the message (4 for auth, 10 for authpriv, etc.).
SYSLOG_IDENTIFIER The process name / tag specified by the logging process (displayed as the process name in the journalctl default output).
Can be freely set by the logging process, for example with logger -t <IDENTIFIER>.
PRIORITY The syslog severity of the message, from 0 (emerg) to 7 (debug).
MESSAGE_ID A 128-bit identifier of the message type, set by some components (notably systemd and systemd-logind). For instance, 8d45620c1a4348dbb17410da57c60c66 for “New session” messages from systemd-logind.
MESSAGE The human-readable message.

The full list of fields is documented in systemd.journal-fields(7).

Journal events

Trusted fields and spoofed entries

As the MESSAGE and SYSLOG_IDENTIFIER fields are set by the logging process, any local user can insert arbitrary messages that appear to originate from another program in the journalctl default output (for example with logger -t sshd "Accepted password for root from 1.2.3.4 port 4444 ssh2").

The trusted fields can be used to identify such entries: a spoofed entry will have the _COMM, _EXE, _UID, and _SYSTEMD_UNIT fields of the actual logging process (for example _COMM=logger and the UID of the user), instead of the values expected for a legitimate entry (for example _COMM=sshd or _COMM=sshd-session with _UID=0 and _SYSTEMD_UNIT=ssh.service / sshd.service).

Thu 2026-10-22 09:14:03.120411 UTC [s=0b6f...;i=1a2f3;b=5c1d...;m=1b2e4f0a;t=6423f...;x=93a1...]
    PRIORITY=5
    SYSLOG_FACILITY=1
    SYSLOG_IDENTIFIER=sshd
    MESSAGE=Accepted password for root from 1.2.3.4 port 4444 ssh2
    _TRANSPORT=syslog
    _UID=1000
    _GID=1000
    _COMM=logger
    _EXE=/usr/bin/logger
    _CMDLINE=logger -t sshd "Accepted password for root from 1.2.3.4 port 4444 ssh2"
    _AUDIT_LOGINUID=1000
    _SYSTEMD_UNIT=session-12.scope
    _SYSTEMD_SESSION=12
    _SYSTEMD_OWNER_UID=1000
    _BOOT_ID=5c1d...
    _HOSTNAME=hostname

Authentication and sessions

Oct 22 08:02:11 hostname sshd[2211]: Accepted password for user from 10.1.2.3 port 51432 ssh2
Oct 22 08:02:11 hostname sshd[2211]: pam_unix(sshd:session): session opened for user user(uid=1000) by (uid=0)
Oct 22 08:02:11 hostname systemd-logind[612]: New session 12 of user user.
Oct 22 08:02:11 hostname systemd[1]: Started session-12.scope - Session 12 of User user.
Oct 22 08:04:52 hostname sshd[2290]: Invalid user admin from 1.2.3.4 port 45843
Oct 22 08:04:55 hostname sshd[2292]: Failed password for root from 1.2.3.4 port 45850 ssh2
Oct 22 08:31:40 hostname sshd[2211]: pam_unix(sshd:session): session closed for user user
Oct 22 08:31:40 hostname systemd-logind[612]: Session 12 logged out. Waiting for processes to exit.
Oct 22 08:31:40 hostname systemd-logind[612]: Removed session 12.

The systemd-logind session identifier (12 in the examples above) matches the _SYSTEMD_SESSION field of the entries emitted by the processes started in the session, which can be used to correlate activity to a given login.

Oct 22 08:10:41 hostname sudo[33630]:     user : TTY=pts/0 ; PWD=/home/user ; USER=root ; COMMAND=/bin/bash
Oct 22 08:10:41 hostname sudo[33630]: pam_unix(sudo:session): session opened for user root(uid=0) by user(uid=1000)

# Example JSON output with all fields for command "sudo cat /etc/shadow" by user "user" (uid 1000).
{"MESSAGE":"    user : TTY=pts/4 ; PWD=/home/user ; USER=root ; COMMAND=/usr/bin/cat /etc/shadow","_SYSTEMD_OWNER_UID":"1000","__CURSOR":"s=1647f77700864dea841733cf98ac5173;i=38ee;b=354deaa7d4bc4de6858b6ad55cd284a0;m=31b65ff1a9;t=6615533096fe2;x=978f730eac40ed7a","_SYSTEMD_SLICE":"user-1000.slice","_SOURCE_REALTIME_TIMESTAMP":"1795868416634788","__MONOTONIC_TIMESTAMP":"213513138601","SYSLOG_TIMESTAMP":"Nov 28 13:20:16 ","_SYSTEMD_USER_SLICE":"-.slice","_UID":"1000","_TRANSPORT":"syslog","_RUNTIME_SCOPE":"system","_CAP_EFFECTIVE":"1ffffffffff","_MACHINE_ID":"c0e312a47da64e1a89d3febe83d1990a","__REALTIME_TIMESTAMP":"1795868416634850","_HOSTNAME":"<HOSTNAME>","SYSLOG_FACILITY":"10","__SEQNUM_ID":"1647f77700864dea841733cf98ac5173","_SYSTEMD_INVOCATION_ID":"c5e8a3e13db2471dbcdc0de53518ed48","PRIORITY":"5","_SYSTEMD_SESSION":"c3","_EXE":"/usr/bin/sudo","_COMM":"sudo","_BOOT_ID":"354deaa7d4bc4de6858b6ad55cd284a0","_SYSTEMD_CGROUP":"/user.slice/user-1000.slice/session-c3.scope","_PID":"2192300","__SEQNUM":"14574","_GID":"1000","_CMDLINE":"sudo cat /etc/shadow","SYSLOG_IDENTIFIER":"sudo","_SYSTEMD_UNIT":"session-c3.scope"}
{"_PID":"2192300","_SYSTEMD_CGROUP":"/user.slice/user-1000.slice/session-c3.scope","_TRANSPORT":"syslog","_SYSTEMD_SLICE":"user-1000.slice","_BOOT_ID":"354deaa7d4bc4de6858b6ad55cd284a0","_SYSTEMD_USER_SLICE":"-.slice","__REALTIME_TIMESTAMP":"1795868416635145","__CURSOR":"s=1647f77700864dea841733cf98ac5173;i=38ef;b=354deaa7d4bc4de6858b6ad55cd284a0;m=31b65ff2d0;t=6615533097109;x=6ce71e379c898363","_SYSTEMD_INVOCATION_ID":"c5e8a3e13db2471dbcdc0de53518ed48","__SEQNUM":"14575","_EXE":"/usr/bin/sudo","_GID":"0","_SYSTEMD_UNIT":"session-c3.scope","_CMDLINE":"sudo cat /etc/shadow","_SYSTEMD_OWNER_UID":"1000","__MONOTONIC_TIMESTAMP":"213513138896","_RUNTIME_SCOPE":"system","__SEQNUM_ID":"1647f77700864dea841733cf98ac5173","SYSLOG_FACILITY":"10","_SOURCE_REALTIME_TIMESTAMP":"1795868416635012","PRIORITY":"6","_CAP_EFFECTIVE":"1ffffffffff","SYSLOG_IDENTIFIER":"sudo","MESSAGE":"pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)","_COMM":"sudo","_HOSTNAME":"<HOSTNAME>","_UID":"1000","SYSLOG_TIMESTAMP":"Nov 28 13:20:16 ","_MACHINE_ID":"c0e312a47da64e1a89d3febe83d1990a","_SYSTEMD_SESSION":"c3"}
{"__MONOTONIC_TIMESTAMP":"213513139947","_MACHINE_ID":"c0e312a47da64e1a89d3febe83d1990a","MESSAGE":"pam_unix(sudo:session): session closed for user root","SYSLOG_FACILITY":"10","SYSLOG_IDENTIFIER":"sudo","__REALTIME_TIMESTAMP":"1795868416636196","__CURSOR":"s=1647f77700864dea841733cf98ac5173;i=38f0;b=354deaa7d4bc4de6858b6ad55cd284a0;m=31b65ff6eb;t=6615533097524;x=8314299f19a82869","_EXE":"/usr/bin/sudo","_GID":"0","_SOURCE_REALTIME_TIMESTAMP":"1795868416636172","SYSLOG_TIMESTAMP":"Nov 28 13:20:16 ","_COMM":"sudo","_PID":"2192300","_CAP_EFFECTIVE":"1ffffffffff","_UID":"1000","__SEQNUM_ID":"1647f77700864dea841733cf98ac5173","_SYSTEMD_OWNER_UID":"1000","PRIORITY":"6","_SYSTEMD_SLICE":"user-1000.slice","_SYSTEMD_SESSION":"c3","_SYSTEMD_INVOCATION_ID":"c5e8a3e13db2471dbcdc0de53518ed48","_HOSTNAME":"<HOSTNAME>","_SYSTEMD_CGROUP":"/user.slice/user-1000.slice/session-c3.scope","_RUNTIME_SCOPE":"system","_SYSTEMD_USER_SLICE":"-.slice","_BOOT_ID":"354deaa7d4bc4de6858b6ad55cd284a0","__SEQNUM":"14576","_SYSTEMD_UNIT":"session-c3.scope","_CMDLINE":"sudo cat /etc/shadow","_TRANSPORT":"syslog"}
Oct 22 08:11:05 hostname useradd[34011]: new group: name=new_user, GID=1001
Oct 22 08:11:05 hostname useradd[34011]: new user: name=new_user, UID=1001, GID=1001, home=/home/new_user, shell=/bin/bash, from=/dev/pts/0

# Example JSON output with all fields:
{"_SYSTEMD_USER_SLICE":"-.slice","MESSAGE":"new user: name=user2, UID=1001, GID=1001, home=/home/user2, shell=/bin/bash, from=/dev/pts/3","_BOOT_ID":"354deaa7d4bc4de6858b6ad55cd284a0","SYSLOG_FACILITY":"10","__SEQNUM":"14256","_SYSTEMD_SLICE":"user-0.slice","_SOURCE_REALTIME_TIMESTAMP":"1795868082020823","_CAP_EFFECTIVE":"1ffffffffff","_HOSTNAME":"<HOSTNAME>","_COMM":"useradd","_EXE":"/usr/sbin/useradd","__CURSOR":"s=1647f77700864dea841733cf98ac5173;i=37b0;b=354deaa7d4bc4de6858b6ad55cd284a0;m=31a26e23ba;t=661551f17a1f4;x=e6393faec7c4a910","_CMDLINE":"/sbin/useradd -d /home/user2 -g 1001 -s /bin/bash -u 1001 user2","_RUNTIME_SCOPE":"system","SYSLOG_PID":"2188070","SYSLOG_IDENTIFIER":"useradd","_SYSTEMD_OWNER_UID":"0","_MACHINE_ID":"c0e312a47da64e1a89d3febe83d1990a","_SYSTEMD_SESSION":"c2","_PID":"2188070","_TRANSPORT":"syslog","_SYSTEMD_UNIT":"session-c2.scope","SYSLOG_TIMESTAMP":"Nov 28 13:14:42 ","_SYSTEMD_INVOCATION_ID":"096bb37f1cf647918ddeff3e6e121665","_GID":"0","__SEQNUM_ID":"1647f77700864dea841733cf98ac5173","__MONOTONIC_TIMESTAMP":"213178524602","__REALTIME_TIMESTAMP":"1795868082020852","_SYSTEMD_CGROUP":"/user.slice/user-0.slice/session-c2.scope","_UID":"0","PRIORITY":"6"}
Oct 22 08:11:18 hostname groupadd[34019]: group added to /etc/group: name=new_group, GID=1002
Oct 22 08:11:18 hostname groupadd[34019]: group added to /etc/gshadow: name=new_group
Oct 22 08:11:18 hostname groupadd[34019]: new group: name=new_group, GID=1002
Oct 22 08:11:26 hostname passwd[34027]: pam_unix(passwd:chauthtok): password changed for new_user
Oct 22 08:11:37 hostname usermod[34035]: add 'new_user' to group 'wheel'
Oct 22 08:11:37 hostname usermod[34035]: add 'new_user' to shadow group 'wheel'

systemd services and timers

systemd logs the lifecycle of its units, which can be used to identify the creation and execution of malicious services or timers.

Oct 22 08:12:03 hostname systemd[1]: Reloading.
Oct 22 08:12:09 hostname systemd[1]: Started update-checker.service - System update checker.
Oct 22 08:12:09 hostname update-checker[34102]: Connecting to 1.2.3.4:443
Oct 22 08:12:10 hostname systemd[1]: update-checker.service: Main process exited, code=exited, status=1/FAILURE
Oct 22 08:12:10 hostname systemd[1]: update-checker.service: Failed with result 'exit-code'.

The output of a service started by systemd is captured by the journal by default (StandardOutput=journal), which may include the output of malicious scripts or binaries executed as a service. All entries of a given unit can be listed with journalctl -u <UNIT>, and the entries of a single execution of the unit with journalctl _SYSTEMD_INVOCATION_ID=<INVOCATION_ID>.

Kernel messages

The kernel messages (_TRANSPORT=kernel, journalctl -k) contain the same information as the syslog kern facility, notably details on plugged-in USB devices (vendor and product identifiers, serial number, etc.), with the advantage of being split by boot. The kernel messages are collected from the kernel ring buffer if the ReadKMsg= option is enabled (default), and can be retrieved from any journal file (current, archived, .journal~, or remote).

On a live system, the kernel ring buffer can be displayed with dmesg. The output of dmesg on a compromised system cannot, however, be fully trusted, and the ring buffer only keeps the most recent messages (with older entries overwritten when the buffer is full). The kernel messages stored in the journal provide a post-mortem and historical alternative.

Oct 22 09:40:12 hostname kernel: usb 1-1: new high-speed USB device number 4 using xhci_hcd
Oct 22 09:40:12 hostname kernel: usb 1-1: New USB device found, idVendor=0781, idProduct=5581, bcdDevice= 1.00
Oct 22 09:40:12 hostname kernel: usb 1-1: Product: Ultra
Oct 22 09:40:12 hostname kernel: usb 1-1: Manufacturer: SanDisk
Oct 22 09:40:12 hostname kernel: usb 1-1: SerialNumber: 4C530001230101115113
Oct 22 09:40:13 hostname kernel: sd 2:0:0:0: [sdb] Attached SCSI removable disk

Boots

Each boot is identified by a _BOOT_ID, which can be used to determine the system startup and shutdown times (with journalctl --list-boots, which displays the first and last entry timestamps of each boot), and to filter entries by boot (journalctl -b <BOOT_OFFSET | BOOT_ID>).

Tool(s)

journalctl

journalctl is the built-in utility to query the journal, on a live system or on journal files / directories collected from another system.

# Input selection.
# By default, journalctl reads the journal of the local system.
# -D / --directory: reads the journal files in the specified directory (for example <MOUNT_POINT>/var/log/journal/<MACHINE_ID>/).
# --file: reads the specified journal file(s), globbing supported (--file "<DIRECTORY>/*.journal*").
# --root: reads the journal files under the specified root directory (for example a mounted disk image).
# --namespace=*: includes the entries from all journal namespaces.

# Output formatting.
# --utc: displays timestamps in UTC instead of local time.
# --no-pager: disables the pager.
# -o / --output: short-iso-precise (ISO 8601 timestamps with microseconds), verbose (all fields), json / json-pretty, export (binary serialization), cat (message only).

# Displays the header of the journal files (including the covered time range).
journalctl --utc --header -D <JOURNAL_DIRECTORY>

# Checks the integrity of the journal files.
journalctl --verify [--verify-key=<VERIFICATION_KEY>] -D <JOURNAL_DIRECTORY>

# Lists the system boots (with their first and last journal entry timestamps).
journalctl --utc --list-boots -D <JOURNAL_DIRECTORY>

# Exports all entries in a syslog-like text format.
journalctl --utc --no-pager -o short-iso-precise -D <JOURNAL_DIRECTORY> > <OUTPUT_FILE>

# Exports all entries, one per line in key-value pairs and converting the _SOURCE_REALTIME_TIMESTAMP timestamp from epoch to ISO in UTC.
# Requires jq.
journalctl --utc -D /var/log/journal -q --no-pager -o json | jq -rR 'fromjson? | (._SOURCE_REALTIME_TIMESTAMP // .__REALTIME_TIMESTAMP) as $t | (($t[:-6] | tonumber | strftime("%Y-%m-%dT%H:%M:%S")) + "." + $t[-6:] + "Z") + " " + ([to_entries[] | "\(.key)=\(.value | if type == "string" then . else tojson end)"] | join(" "))'

# Exports all entries in JSON (one entry per line, all fields).
journalctl --utc --no-pager -o json --all -D <JOURNAL_DIRECTORY> > <OUTPUT_FILE>

# Exports all entries in JSON (one entry per line, all fields), converting the _SOURCE_REALTIME_TIMESTAMP timestamp from epoch to ISO in UTC.
# Requires jq.
journalctl --utc --no-pager -o json --all -D <JOURNAL_DIRECTORY> | jq -cR 'fromjson? | (._SOURCE_REALTIME_TIMESTAMP // .__REALTIME_TIMESTAMP) as $t | .timestamp = (($t[:-6] | tonumber | strftime("%Y-%m-%dT%H:%M:%S")) + "." + $t[-6:] + "Z")' > <OUTPUT_FILE>

# Filters on a time range (-S / --since and -U / --until).
# Timestamp format: "YYYY-MM-DD hh:mm:ss" (interpreted in local time, unless suffixed with " UTC").
journalctl --utc --since "<START_TIME>" --until "<END_TIME>" -D <JOURNAL_DIRECTORY>

# Filters on a boot, a systemd unit, a syslog identifier, or the kernel messages.
journalctl --utc -b <BOOT_OFFSET | BOOT_ID>  -D <JOURNAL_DIRECTORY>
journalctl --utc -u <UNIT> -D <JOURNAL_DIRECTORY>
journalctl --utc -t <SYSLOG_IDENTIFIER> -D <JOURNAL_DIRECTORY>
journalctl --utc -k -D <JOURNAL_DIRECTORY>

# Filters on any field (multiple filters on different fields are combined with AND, on the same field with OR).
journalctl --utc _COMM=sshd -D <JOURNAL_DIRECTORY>
journalctl --utc _UID=<UID> -D <JOURNAL_DIRECTORY>
journalctl --utc _SYSTEMD_SESSION=<SESSION_ID> -D <JOURNAL_DIRECTORY>
journalctl --utc _EXE=<EXECUTABLE_PATH> -D <JOURNAL_DIRECTORY>

# Filters on a transport (driver, syslog, journal, stdout, kernel, or audit).
journalctl --utc _TRANSPORT=<TRANSPORT> -D <JOURNAL_DIRECTORY>

# Filters on the message content (regex, case-insensitive if the pattern is in lowercase).
# Only the MESSAGE field is searched, other fields (such as _CMDLINE) are not.
journalctl --utc -g "<PATTERN>" -D <JOURNAL_DIRECTORY>

# Lists all the distinct values of a field (for example all the units or executables that logged entries).
journalctl -F _SYSTEMD_UNIT -D <JOURNAL_DIRECTORY>
journalctl -F _EXE -D <JOURNAL_DIRECTORY>

dissect target-query

The target-query tool, part of the dissect Python framework, can be used to parse journal files into CSV or JSON output, including from a Windows analysis system.

# To parse a journal directory directly, the files must be placed under <TARGET>/var/log/journal/.

target-query -f journal <TARGET> | rdump <--csv | --json | --jsonlines>

plaso

plaso supports the journal files through its systemd_journal parser, for integration in a super timeline.

log2timeline.py --parsers systemd_journal --storage-file <OUTPUT_PLASO_FILE> <JOURNAL_DIRECTORY>
psort.py -o dynamic -w <OUTPUT_CSV_FILE> <OUTPUT_PLASO_FILE>

References



View on GitHub