1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
'\" t
.\" Title: last
.\" Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.20
.\" Date: 2025-12-15
.\" Manual: User Commands
.\" Source: util-linux 2.41.3
.\" Language: English
.\"
.TH "LAST" "1" "2025-12-15" "util\-linux 2.41.3" "User Commands"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
. mso www.tmac
. am URL
. ad l
. .
. am MTO
. ad l
. .
. LINKSTYLE blue R < >
.\}
.SH "NAME"
last, lastb \- show a listing of last logged in users
.SH "SYNOPSIS"
.sp
\fBlast\fP [options] [\fIusername\fP...] [\fItty\fP...]
.sp
\fBlastb\fP [options] [\fIusername\fP...] [\fItty\fP...]
.SH "DESCRIPTION"
.sp
\fBlast\fP searches back through the \fI/var/log/wtmp\fP file (or the file designated by the \fB\-f\fP option) and displays a list of all users logged in (and out) since that file was created. One or more \fIusernames\fP and/or \fIttys\fP can be given, in which case \fBlast\fP will show only the entries matching those arguments. Names of \fIttys\fP can be abbreviated, thus \fBlast 0\fP is the same as \fBlast tty0\fP.
.sp
When catching a \fBSIGINT\fP signal (generated by the interrupt key, usually control\-C) or a \fBSIGQUIT\fP signal, \fBlast\fP will show how far it has searched through the file; in the case of the \fBSIGINT\fP signal \fBlast\fP will then terminate.
.sp
The pseudo user \fBreboot\fP logs in each time the system is rebooted. Thus \fBlast reboot\fP will show a log of all the reboots since the log file was created.
.sp
\fBlastb\fP is the same as \fBlast\fP, except that by default it shows a log of the \fI/var/log/btmp\fP file, which contains all the bad login attempts.
.SH "OPTIONS"
.sp
\fB\-a\fP, \fB\-\-hostlast\fP
.RS 4
Display the hostname in the last column. Useful in combination with the \fB\-\-dns\fP option.
.RE
.sp
\fB\-d\fP, \fB\-\-dns\fP
.RS 4
For non\-local logins, Linux stores not only the host name of the remote host, but its IP number as well. This option translates the IP number back into a hostname.
.RE
.sp
\fB\-f\fP, \fB\-\-file\fP \fIfile\fP
.RS 4
Tell \fBlast\fP to use a specific \fIfile\fP instead of \fI/var/log/wtmp\fP. The \fB\-\-file\fP option can be given multiple times, and all of the specified files will be processed.
.RE
.sp
\fB\-F\fP, \fB\-\-fulltimes\fP
.RS 4
Print full login and logout times and dates.
.RE
.sp
\fB\-i\fP, \fB\-\-ip\fP
.RS 4
Like \fB\-\-dns ,\fP but displays the host\(cqs IP number instead of the name.
.RE
.sp
\fB\-\fP\fInumber\fP; \fB\-n\fP, \fB\-\-limit\fP \fInumber\fP
.RS 4
Tell \fBlast\fP how many lines to show.
.RE
.sp
\fB\-p\fP, \fB\-\-present\fP \fItime\fP
.RS 4
Display the users who were present at the specified time. This is like using the options \fB\-\-since\fP and \fB\-\-until\fP together with the same \fItime\fP.
.RE
.sp
\fB\-R\fP, \fB\-\-nohostname\fP
.RS 4
Suppresses the display of the hostname field.
.RE
.sp
\fB\-s\fP, \fB\-\-since\fP \fItime\fP
.RS 4
Display the state of logins since the specified \fItime\fP. This is useful, e.g., to easily determine who was logged in at a particular time. The option is often combined with \fB\-\-until\fP.
.RE
.sp
\fB\-t\fP, \fB\-\-until\fP \fItime\fP
.RS 4
Display the state of logins until the specified \fItime\fP.
.RE
.sp
\fB\-T\fP, \fB\-\-tab\-separated\fP
.RS 4
Use ASCII \fBtab\fP characters to separate the columns in the output instead of spaces.
.RE
.sp
\fB\-\-time\-format\fP \fIformat\fP
.RS 4
Define the output timestamp \fIformat\fP to be one of \fInotime\fP, \fIshort\fP, \fIfull\fP, or \fIiso\fP. The \fInotime\fP variant will not print any timestamps at all, \fIshort\fP is the default, and \fIfull\fP is the same as the \fB\-\-fulltimes\fP option. The \fIiso\fP variant will display the timestamp in ISO\-8601 format. The ISO format contains timezone information, making it preferable when printouts are investigated outside of the system.
.RE
.sp
\fB\-w\fP, \fB\-\-fullnames\fP
.RS 4
Display full user names and domain names / IP addresses in the output. Domain names and IP addresses are truncated to 16 characters, and user names are truncated to 8 characters when this flag is not specified. An asterisk is set as the last character of truncated fields.
.RE
.sp
\fB\-x\fP, \fB\-\-system\fP
.RS 4
Display the system shutdown entries and run level changes.
.RE
.sp
\fB\-h\fP, \fB\-\-help\fP
.RS 4
Display help text and exit.
.RE
.sp
\fB\-V\fP, \fB\-\-version\fP
.RS 4
Display version and exit.
.RE
.SH "TIME FORMATS"
.sp
The options that take the \fItime\fP argument understand the following formats:
.TS
allbox tab(:);
lt lt.
T{
.sp
YYYYMMDDhhmmss
T}:T{
.sp
T}
T{
.sp
YYYY\-MM\-DD hh:mm:ss
T}:T{
.sp
T}
T{
.sp
YYYY\-MM\-DD hh:mm
T}:T{
.sp
(seconds will be set to 00)
T}
T{
.sp
YYYY\-MM\-DD
T}:T{
.sp
(time will be set to 00:00:00)
T}
T{
.sp
hh:mm:ss
T}:T{
.sp
(date will be set to today)
T}
T{
.sp
hh:mm
T}:T{
.sp
(date will be set to today, seconds to 00)
T}
T{
.sp
now
T}:T{
.sp
T}
T{
.sp
yesterday
T}:T{
.sp
(time is set to 00:00:00)
T}
T{
.sp
today
T}:T{
.sp
(time is set to 00:00:00)
T}
T{
.sp
tomorrow
T}:T{
.sp
(time is set to 00:00:00)
T}
T{
.sp
+5min
T}:T{
.sp
T}
T{
.sp
\-5days
T}:T{
.sp
T}
.TE
.sp
.SH "FILES"
.sp
\fI/var/log/wtmp\fP,
\fI/var/log/btmp\fP
.SH "NOTES"
.sp
The files \fIwtmp\fP and \fIbtmp\fP might not be found. The system only logs information in these files if they are present. This is a local configuration issue. If you want the files to be used, they can be created with a simple \fBtouch\fP(1) command (for example, \fBtouch /var/log/wtmp\fP).
.sp
An empty entry is a valid type of wtmp entry. It means that an empty file or file with zeros is not interpreted as an error.
.sp
The utmp file format uses fixed sizes of strings, which means that very long strings are impossible to store in the file and impossible to display by \fBlast\fP. The usual limits are 32 bytes for a user and line name and 256 bytes for a hostname.
.SH "AUTHORS"
.sp
.MTO "miquels\(atcistron.nl" "Miquel van Smoorenburg" ""
.SH "SEE ALSO"
.sp
\fBlogin\fP(1),
\fBwtmp\fP(5),
\fBinit\fP(8),
\fBshutdown\fP(8)
.SH "REPORTING BUGS"
.sp
For bug reports, use the \c
.URL "https://github.com/util\-linux/util\-linux/issues" "issue tracker" "."
.SH "AVAILABILITY"
.sp
The \fBlast\fP command is part of the util\-linux package which can be downloaded from \c
.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."
|