# Lastlog

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Lastlog
> Markdown URL: https://mediated.wiki/source/Lastlog.md
> Source: https://en.wikipedia.org/wiki/Lastlog
> Source revision: 1287739955
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

'''lastlog''' is a program available on most [Linux distributions](/source/Linux_distributions). It formats and prints the contents of the last login log file, <code>/var/log/lastlog</code> (which is a usually a very sparse file), including the login name, port, and last login date and time.  It is similar in functionality to the [BSD](/source/BSD) program '''last''', also included in Linux distributions; however, '''last''' parses a different binary database file (<code>[/var/log/wtmp](/source/Utmp)</code> and <code>/var/log/btmp</code>).

The file is updated by the <code>pam_lastlog.so</code> [Pluggable Authentication Module](/source/Pluggable_Authentication_Module).<ref>{{cite web |title=linux-pam source code |url=https://github.com/linux-pam/linux-pam/blob/bc856cd9b9b461e8e2a537f4d9db87d315f5fe7b/modules/pam_lastlog/pam_lastlog.c#L6-L8 |website=Github |access-date=2025-04-21 |ref=src}}</ref> The module has been deprecated since 2023, and is announced to be removed in future releases of the pam-linux framework, due to the data structures inherently being affected by the [Year 2038 problem](/source/Year_2038_problem).<ref>{{cite web |title=linux-pam NEWS document |url=https://github.com/linux-pam/linux-pam/blob/bc856cd9b9b461e8e2a537f4d9db87d315f5fe7b/NEWS#L76-L78 |website=github |access-date=2025-04-21}}</ref>

== Usage ==
Lastlog prints its output in column format with login-name, port, and last-login-time of each and every user on the system mentioned in that order. The users are sorted by default according to the order in <code>/etc/passwd</code> However, it can also be used to modify the records kept in <code>/var/log/lastlog</code>.<syntaxhighlight lang="console">
$ lastlog
Username         Port     From             Latest
root                                       **Never logged in**
user            tty3                        Sun Jan 14 16:29:24 +0130 2019
</syntaxhighlight>

== References ==
{{Reflist}}

== External links ==
* {{man|8|lastlog|die.net}}

{{Unix commands}}

Category:Unix user management and support-related utilities

---
Adapted from the Wikipedia article [Lastlog](https://en.wikipedia.org/wiki/Lastlog) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Lastlog?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
