Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Thursday, December 3, 2026

What Happened to the last Command in Ubuntu 26.04 LTS?

December 3, 2026 | Linux, Ubuntu Server, System Administration

If you have recently installed or upgraded to Ubuntu 26.04 LTS, you may have noticed that the familiar last command is missing.

For decades, Linux system administrators have used this command to inspect user login history, identify remote connections, investigate suspicious activity, and determine when a server was rebooted.

Fortunately, the functionality has not disappeared. It has been replaced by a more modern implementation called wtmpdb.

Why Was the last Command Replaced?

Traditionally, the last command was provided by the util-linux package and retrieved login and logout information from the binary file:

/var/log/wtmp

One of the limitations of this traditional file format is its vulnerability to the Year 2038 problem, caused by the use of signed 32-bit Unix timestamps.

The new implementation, wtmpdb, addresses this limitation by using an SQLite database and 64-bit timestamps.

The transition offers several benefits:

  • Compatibility with dates beyond January 2038.

  • SQLite-based storage.

  • Modern login and logout tracking.

  • Continued support for familiar command-line options.

  • Integration with Pluggable Authentication Modules (PAM).

Installing wtmpdb on Ubuntu 26.04

The replacement may not be installed by default on your server.

To install it, execute:

sudo apt update
sudo apt install wtmpdb libpam-wtmpdb

The two packages serve different purposes:

PackagePurpose
wtmpdbDisplays login, logout and reboot history.
libpam-wtmpdbRecords user login and logout events through PAM.

Both packages are available in the Ubuntu Universe repository.

If Universe is not enabled, execute:

sudo add-apt-repository universe
sudo apt update

Using the New last Command

The direct replacement for the traditional command is:

wtmpdb last

If the compatibility command is installed, you can continue using:

last

You can verify its availability with:

command -v last

Display the Last 10 Login Records

wtmpdb last -n 10

Display Server Reboot History

wtmpdb last reboot

Display Login History for a Specific User

wtmpdb last username

Display Full Login and Logout Timestamps

wtmpdb last -F

Display IP Addresses Instead of Hostnames

wtmpdb last -i

Display All Available Options

wtmpdb last --help

Where Is Login History Stored?

Instead of using the traditional binary file, wtmpdb uses an SQLite database.

The database location used by the Ubuntu packaging is:

/var/lib/wtmpdb/wtmp.db

The following compatibility path may also be available:

/var/log/wtmp.db

You can inspect these locations using:

ls -l /var/lib/wtmpdb/ /var/log/wtmp*

It is important to understand that installing wtmpdb does not automatically reconstruct all previous login records. Existing historical records may need to be imported separately.

Alternatives Using systemd

If you prefer not to install additional packages, Ubuntu provides several useful alternatives through systemd.

Display System Reboot History

journalctl --list-boots

This command displays the system boots retained in the systemd journal.

Display SSH Login Activity

sudo journalctl -u ssh.service

Display Successful SSH Logins

sudo journalctl -u ssh.service | grep 'Accepted'

Display Failed SSH Password Attempts

sudo journalctl -u ssh.service | grep 'Failed password'

Display SSH Activity for the Current Day

sudo journalctl -u ssh.service --since today

Display Currently Logged-In Users

loginctl list-sessions

Although these commands provide valuable information, they are not exact replacements for the traditional login history database. Their historical coverage depends on journal retention and configuration.

Comparison with Previous Ubuntu LTS Releases

FeatureUbuntu 22.04 / 24.04Ubuntu 26.04
Login history utilitylastwtmpdb last
Packageutil-linuxwtmpdb
Storage formatBinary recordsSQLite
Traditional database/var/log/wtmp/var/lib/wtmpdb/wtmp.db
Year 2038 safeNoYes
Additional installationGenerally unnecessaryMay be required

Recommendations for Production Servers

When deploying a new Ubuntu 26.04 LTS server, consider including the following packages in your standard server provisioning procedure:

sudo apt install wtmpdb libpam-wtmpdb

After installation, establish a new SSH session, disconnect, and verify that the login and logout events have been recorded.

wtmpdb last -n 10

If you maintain shell scripts or automated monitoring tools that depend on the traditional last command, review their compatibility with the new implementation, particularly if they parse its output.

For portability across different Ubuntu releases, scripts can detect which implementation is available:

if command -v wtmpdb >/dev/null 2>&1; then
    wtmpdb last -n 10
elif command -v last >/dev/null 2>&1; then
    last -n 10
else
    echo "No login history utility available." >&2
    exit 1
fi

This approach allows the same script to operate across older and newer Ubuntu servers.

Conclusion

The disappearance of the traditional last command in Ubuntu 26.04 LTS is part of the modernization of Linux login accounting rather than the removal of an important system administration feature.

The wtmpdb package provides a replacement based on SQLite that addresses the Year 2038 problem while preserving much of the familiar command-line functionality.

For system administrators managing Ubuntu 26.04 production servers, installing wtmpdb and its associated PAM module is a straightforward way to maintain access to user login history.

References

Tags: Ubuntu, Ubuntu 26.04 LTS, Linux, System Administration, wtmpdb, last, SSH, Security, Year 2038