wtmp, btmp and utmp: Linux login records

wtmp, btmp and utmp are the binary files where Linux records logins: /var/log/wtmp keeps the history of logins, logouts and reboots, /var/log/btmp keeps failed login attempts, and /var/run/utmp lists who is logged in right now.

LinuxLogonsRead with last, lastb, who, utmpdumpChecked 1 December 2026

The three files

FilePathRecordsRead with
utmp/var/run/utmp (/run/utmp)Sessions open right now: user, terminal, source host, login time. Cleared at boot.who, w, utmpdump /var/run/utmp
wtmp/var/log/wtmpEvery login and logout, plus reboots and shutdowns and run-level changes, appended over time.last, utmpdump /var/log/wtmp
btmp/var/log/btmpFailed login attempts: user name tried, terminal, source host, time.lastb (as root), utmpdump /var/log/btmp
lastlog/var/log/lastlogThe most recent login of each account, indexed by UID.lastlog

All four are binary files made of fixed-size records, so they cannot be read with cat or a text editor. Log rotation keeps older copies (wtmp.1, btmp.1, sometimes compressed), and on many distributions btmp is rotated monthly and wtmp kept for a few months.

Some current distributions are moving away from these files: systemd systems can record logins through systemd-logind and the journal, and newer releases may ship without utmp support or replace wtmp with a database. Check which files exist on the system before concluding that a login left no record.

Reading them with last, lastb and utmpdump

# login history, newest first, with full times and source addresses
last -F -i -f /var/log/wtmp

# failed attempts (root needed)
lastb -F -i -f /var/log/btmp

# every field of every record, including ones last hides
utmpdump /var/log/wtmp

# last login of each account
lastlog

On an image, point the tools at the copied file with -f rather than running them against the analyst machine's own records. utmpdump shows every record, including dead process entries and the exact time values, and is the most reliable way to read a file that may have been tampered with.

A line in last such as root pts/1 203.0.113.77 Tue Nov 24 02:58:12 2026 - 03:31:40 (00:33) says root had a session on pseudo-terminal pts/1 from 203.0.113.77 for 33 minutes. "still logged in" means no logout record was written, which also happens when a session ended by crash or reboot. "gone - no logout" is the same, seen after a reboot.

What login records prove, and what they do not

  • They show which account logged in to which terminal, from which host or address, and when, for logins made through programs that write these files: sshd, login on consoles, some display managers.
  • They show reboots and shutdowns (the reboot pseudo-user in last), which bound uptime and the life of every session.
  • btmp shows the user names tried in failed logins and where from, which separates guessing from mistyping and reveals usernames an attacker tried.
  • They do not show what the user did in the session. Use shell history, auditd and the journal for that.
  • They do not cover every access. Commands run over SSH without a terminal (scp, sftp, ssh host command), cron jobs and many service logins write no utmp or wtmp record, while the SSH daemon still logs them in auth.log, secure or the journal.
  • They are easy to tamper with. Any root user can edit or truncate them, and log-cleaning tools target them specifically.

Signs of tampering

  • wtmp shorter than expected, or starting long after the system's install date, with no rotated copies.
  • Gaps: a reboot recorded in the journal but not in wtmp, or SSH logins in auth.log with no matching wtmp entry.
  • Records out of time order, or entries with zeroed fields, visible in utmpdump output.
  • File modification time of wtmp or btmp much later than its last record, or a size of zero.
  • Tools such as utmpdump used in reverse (dump, edit, re-import) leave the file valid but altered; compare against auth.log and the journal.

Because the files are so easy to edit, login records should always be read next to the SSH daemon's own log lines (auth.log on Debian and Ubuntu, secure on Red Hat family systems, or the journal), which an attacker would have to alter separately.

In a real investigation: Halden Freight portal breach

In our Linux lab case, the attacker reached the web server through a vulnerable WordPress plugin and later logged in as root over SSH with a planted key from 203.0.113.77, then moved to the database server. The SSH logins appear in auth.log as accepted public-key logins for root from that address, and Arcsentry rebuilt them into sessions with their source and duration, alongside the web server account's commands from auditd. The same case had 2,817 SSH brute-force attempts from other addresses across the two servers, none of which ever logged in, which is exactly the question failed-login records exist to answer. The full walk-through is in the Halden Freight case study.

Login records in Arcsentry

When Arcsentry Collector collects a live Linux host, it runs utmpdump over utmp, wtmp and btmp and records lastlog, and Arcsentry parses the output into login records with user, terminal, source address and time. On every Linux collection, live or from a disk image, Arcsentry also reads the authentication logs, the systemd journal and sudo and su records, and rebuilds logon, terminal and privilege sessions from them, so SSH logins are covered even when wtmp was cleared. Find failed SSH logins by source in AQL:

filter event_type == "syslog" && message ~= "(?i)(failed password|invalid user)"
group {source_ip} (aggregate {attempts = count this, first_seen = (earliest timestamp), last_seen = (latest timestamp)})
sort {-attempts}

Then check whether any of those addresses ever logged in, in the sessions view or with the same query on "Accepted". See tracing lateral movement through SSH logs for the full method.

Arcsentry parsers for Linux logins

The login records themselves, and the sources Arcsentry uses alongside them to rebuild Linux sessions:

ArtifactWhat Arcsentry extracts
UtmpdumpParse utmp and wtmp binary files into readable format.
LastlogLast login records with optional terminal and source host columns.
SyslogParses Linux syslog and auth.log files.
Sudo LogParses sudo command execution log entries.
Systemd JournalParses systemd journal binary log files.
Logind Sessionssystemd-logind live session state: account, seat, TTY, PAM service, session type and class, leader PID, and session start.
LoginctlPer-user systemd-logind properties captured with loginctl show-user.
Command HistoryParses shell and interactive interpreter command history files (bash, zsh, fish, ash and other shells, Python, Node.js, irb and database shell clients such as psql, MySQL and Redis).
SSH Authorized KeysSSH authorized_keys entries, showing who can log in, with which key, and under which forced options.

Frequently asked

What is the difference between wtmp, btmp and utmp?

utmp lists the sessions open now and is cleared at boot. wtmp keeps the history of logins, logouts, reboots and shutdowns. btmp keeps failed login attempts. All three are binary files in the same record format.

How do I read /var/log/wtmp?

Use last (last -F -i for full times and addresses) or utmpdump /var/log/wtmp to see every field. For a copied file from an image, add -f with its path.

How do I see failed login attempts on Linux?

Run lastb as root, which reads /var/log/btmp, or utmpdump /var/log/btmp. Failed SSH logins are also logged by sshd in /var/log/auth.log, /var/log/secure or the journal ("Failed password", "Invalid user").

How do I check Linux login history?

last shows logins and logouts from wtmp; lastlog shows each account's most recent login; and the SSH daemon's lines in auth.log, secure or journalctl -u sshd show SSH logins, including ones that do not write to wtmp.

Can wtmp be deleted or edited?

Yes, by root. Attackers truncate it or remove entries with log-cleaning tools. Compare it with the SSH daemon's log lines and the journal, and look for gaps, out-of-order records and a modification time later than the last record.

Why does last say "still logged in"?

No logout record was written for the session. Either it is still open (check who or utmp), or it ended without a clean logout because of a crash, a reboot or a killed process.

Sources

  • Linux man pages: utmp(5), wtmp(5), last(1), lastb(1), utmpdump(1), lastlog(8)
  • Venema Labs lab case: Halden Freight portal breach (web01 and db01)

Checked 1 December 2026 by Venema Labs. Parser coverage is generated from the Arcsentry build the artifact library describes.

Rebuild every Linux login session from your own evidence.

Tell us what you want to investigate. A person replies within one business day with the download and a trial licence.

Request a trial