LinuxCommandLibrary

last

TLDR

View all login history

$ last
copy
View logins for a specific user
$ last username
copy
Show last 10 logins
$ last -n 10
copy
Show logins with full timestamps
$ last -F
copy
Show logins with IP addresses instead of hostnames
$ last -i
copy
Show logins since a specific date
$ last -s -7days
copy
View system reboots
$ last reboot
copy
View failed logins (requires root)
$ lastb
copy

SYNOPSIS

last [options] [username...] [tty...]

DESCRIPTION

last searches back through the /var/log/wtmp file and displays a list of all users logged in and out since that file was created. The related lastb command shows failed login attempts from /var/log/btmp.

PARAMETERS

-a, --hostlast

Display the hostname in the last column
-d, --dns
Translate IP addresses to hostnames for remote logins
-f, --file FILE
Use a different file instead of /var/log/wtmp
-F, --fulltimes
Print full login and logout times and dates
-i, --ip
Display IP addresses instead of hostnames
-n, --limit NUM
Show only the specified number of lines
-R, --nohostname
Do not display the hostname field
-s, --since TIME
Display logins since the specified time
-t, --until TIME
Display logins until the specified time
-w, --fullnames
Display full user and domain names
-x, --system
Display system shutdown entries and runlevel changes
--time-format FORMAT
Define output time format (notime, short, full, iso)

CAVEATS

The pseudo-user "reboot" logs entries each time the system is restarted, allowing boot history tracking. The wtmp and btmp files must exist; administrators may need to create them using touch.

HISTORY

last has been a standard Unix utility since the early BSD systems, providing user login accounting functionality.

SEE ALSO

lastb(1), who(1), w(1), utmp(5)

> TERMINAL_GEAR

Curated for the Linux community

Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

KIWITATA 2X Classic SNES USB Controller for PC Gamings, Retro SNES Wired USB Game Emulator Controller for Windows XP 7 8 11 Mac Raspberry Pi

$16.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50