Linux login history with w, last and lastb
Where Linux stores logins (wtmp, utmp, btmp) and how to read them with w, last and lastb.
Files and commands to review past logins, open sessions and failed login attempts on Linux.
Log files
| File | Content |
|---|---|
/var/log/wtmp |
History of login sessions |
/var/run/utmp |
Login sessions currently open |
/var/log/btmp |
Failed login attempts |
Commands
w
last
last -i
last -N
lastb
last -f /var/log/btmp
| Command | Effect |
|---|---|
w |
Lists the logged-in users and what they are doing |
last |
Shows the login history (reads wtmp) |
last -i |
Shows IP addresses instead of host names |
last -N |
Limits the output to the last N logins (replace N with a number) |
lastb |
Shows failed login attempts (reads btmp) |
last -f /var/log/btmp |
Same as lastb |