$linuxjunkies
>

last(1)

Show a listing of last logins and logouts on the system.

UbuntuDebianFedoraArch

Synopsis

last [OPTION]... [USER]... [TTY]...

Description

The last command displays a list of last logged in users, extracted from the /var/log/wtmp file. It shows login/logout times, connection duration, and terminal information for each session.

By default, last shows the most recent entries first. You can filter by username, terminal, or other criteria to narrow the results.

Common options

FlagWhat it does
-f FILERead from FILE instead of /var/log/wtmp
-n NUMShow only NUM lines of output
-aDisplay the hostname in the last column instead of in a separate column
-dInterpret addresses as IPv4 dotted notation and hostnames or IPv6 addresses
-FPrint full login and logout times and dates
-iDisplay IP addresses instead of hostnames
-pSuppress the <code>name of the pseudo or console device</code> column
-t YYYYMMDDHHMMSSShow only logins before the specified timestamp
-wDisplay full user names and domain names
-xDisplay the system shutdown or reboot entries and run level changes

Examples

Display all login/logout records in reverse chronological order

last

Show the 10 most recent login/logout entries

last -n 10

Show all login/logout records for user 'john'

last john

Display login records with IP addresses instead of hostnames

last -i

Show login times with full date and time format

last -F

Show system shutdowns, reboots, and runlevel changes (limit to 20 entries)

last -x | head -20

View login history from an archived wtmp log file

last -f /var/log/wtmp.1

Show login records for the specific terminal pts/0

last pts/0

Related commands