LASTLOG(8)
๐ LASTLOG(8) ๐
okay bestie, gather round, because this one is literally the receipts of who logged in last. it's lastlog, it lives in the System Management Commands corner of the manual, and it is lowkey iconic.
โจ NAME โจ
lastlog โ reports the most recent login of all users or of a given user ๐ซถ
๐ธ SYNOPSIS ๐ธ
lastlog [options]
๐ฆ DESCRIPTION ๐ฆ
so what does she actually do? lastlog formats and prints the contents of the last login log โ that's the /var/log/lastlog file, no cap. the login-name, the port, and the last login time all get printed. ๐
the default (like, zero flags, just vibes) causes lastlog entries to be printed, sorted by their order in /etc/passwd. periodt.
๐ OPTIONS ๐
these are the options that apply to the lastlog command, and yes we're going through every single one:
-b,--beforeDAYS โ print only lastlog records older than DAYS. it's giving "show me the ancients". ๐-C,--clearโ clear lastlog record of a user. bestie, this option can be used only together with-u(--user)). don't try it solo, she will not cooperate.-h,--helpโ display help message and exit. the classic "help me please" move. ๐-R,--rootCHROOT_DIR โ apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. only absolute paths are supported, so no shortcuts bestie. ๐ซ-S,--setโ set lastlog record of a user to the current time. this one can be used only together with-u(--user)). same rule as-C, she's not a solo act. โจ-t,--timeDAYS โ print the lastlog records more recent than DAYS. main character energy only. ๐-u,--userLOGIN|RANGE โ print the lastlog record of the specified user(s).
the users can be specified by a login name, a numerical user ID, or a RANGE of users. and this RANGE of users can be specified with a min and max values (UID_MIN-UID_MAX), a max value (-UID_MAX), or a min value (UID_MIN-). pick your fighter. ๐
if the user has never logged in, the message ** Never logged in** will be displayed instead of the port and time. ghosted by your own login history fr fr. ๐ญ
only the entries for the current users of the system will be displayed. other entries may exist for users that were deleted previously โ so yeah, there's lore in there. ๐
๐ NOTE ๐
the lastlog file is a database which contains info on the last login of each user. you should not rotate it. do not. nope. ๐
it's a sparse file, so its size on the disk is usually much smaller than the one shown by ls -l โ which can indicate a really big file if you have in passwd users with a high UID. the way that number lies to you is honestly rude. ๐
you can display its real size with ls -s. use that one instead, iykyk. ๐
โ๏ธ CONFIGURATION โ๏ธ
the following configuration variables in /etc/login.defs change the behavior of this tool:
LASTLOG_UID_MAX (number) ๐
highest user ID number for which the lastlog entries should be updated. as higher user IDs are usually tracked by remote user identity and authentication services, there is no need to create a huge sparse lastlog file for them. like, why would you. ๐ธ
no LASTLOG_UID_MAX option present in the configuration means that there is no user ID limit for writing lastlog entries.
๐ FILES ๐
/var/log/lastlogโ database times of previous user logins. this is the file, the whole plot. ๐
โ ๏ธ CAVEATS โ ๏ธ
large gaps in UID numbers will cause the lastlog program to run longer with no output to the screen โ i.e. if in lastlog database there is no entries for users with UID between 170 and 800, lastlog will appear to hang as it processes entries with UIDs 171-799. it's not frozen bestie, she's just going through it. ๐ซ
having high UIDs can create problems when handling the /var/log/lastlog with external tools. although the actual file is sparse and does not use too much space, certain applications are not designed to identify sparse files by default and may require a specific option to handle them. so like, read the docs before you blame the file. ๐
ok that's the whole page, every option, every number, every caveat, nothing skipped, we ate and left no crumbs ๐ โจ
this lil masterpiece is from shadow-utils 4.13, dated 05/30/2024 โ and LASTLOG(8) said what she said. bye bestie, go check your login history ๐ฆ๐๐
๐ฆ where this page comes from
- ubuntu noble: login 1:4.13+dfsg1-4ubuntu3.2 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms