xref: /freebsd/usr.bin/last/last.1 (revision bdcbfde31e8e9b343f113a1956384bdf30d1ed62)
19b50d902SRodney W. Grimes.\" Copyright (c) 1980, 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
59b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
69b50d902SRodney W. Grimes.\" are met:
79b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
89b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
99b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
109b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
119b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
139b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
149b50d902SRodney W. Grimes.\"    without specific prior written permission.
159b50d902SRodney W. Grimes.\"
169b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
179b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
189b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
209b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
219b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
229b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
239b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
249b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
259b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
269b50d902SRodney W. Grimes.\" SUCH DAMAGE.
279b50d902SRodney W. Grimes.\"
28*53c8d224SFernando Apesteguía.Dd January 9, 2021
299b50d902SRodney W. Grimes.Dt LAST 1
3062500372SRuslan Ermilov.Os
319b50d902SRodney W. Grimes.Sh NAME
329b50d902SRodney W. Grimes.Nm last
339b50d902SRodney W. Grimes.Nd indicate last logins of users and ttys
349b50d902SRodney W. Grimes.Sh SYNOPSIS
358fe908efSRuslan Ermilov.Nm
36c7c5d8e3SPhilip Paeps.Op Fl -libxo
37a3092ad9STim J. Robbins.Op Fl swy
388a242856SDima Dorfman.Oo
398a242856SDima Dorfman.Fl d
408a242856SDima Dorfman.Sm off
418a242856SDima Dorfman.Op Oo Ar CC Oc Ar YY
428a242856SDima Dorfman.Op Ar MM DD
438a242856SDima Dorfman.Ar hh mm
448a242856SDima Dorfman.Op Ar .SS
458a242856SDima Dorfman.Sm on
468a242856SDima Dorfman.Oc
479b50d902SRodney W. Grimes.Op Fl f Ar file
489b50d902SRodney W. Grimes.Op Fl h Ar host
49b28e0896STim J. Robbins.Op Fl n Ar maxrec
509b50d902SRodney W. Grimes.Op Fl t Ar tty
51756ceae8SRuslan Ermilov.Op Ar user ...
529b50d902SRodney W. Grimes.Sh DESCRIPTION
53e8937ba0SPhilippe CharnierThe
54e8937ba0SPhilippe Charnier.Nm
55e8937ba0SPhilippe Charnierutility will either list the sessions of specified
569b50d902SRodney W. Grimes.Ar users ,
579b50d902SRodney W. Grimes.Ar ttys ,
589b50d902SRodney W. Grimesand
599b50d902SRodney W. Grimes.Ar hosts ,
608a242856SDima Dorfmanin reverse time order,
618a242856SDima Dorfmanor list the users logged in at a specified date and time.
62ea0aee12SDima DorfmanEach line of output contains
639b50d902SRodney W. Grimesthe user name, the tty from which the session was conducted, any
649b50d902SRodney W. Grimeshostname, the start and stop times for the session, and the duration
65ea0aee12SDima Dorfmanof the session.
66ea0aee12SDima DorfmanIf the session is still continuing or was cut short by
679b50d902SRodney W. Grimesa crash or shutdown,
688fe908efSRuslan Ermilov.Nm
699b50d902SRodney W. Grimeswill so indicate.
709b50d902SRodney W. Grimes.Pp
71e8937ba0SPhilippe CharnierThe following options are available:
729b50d902SRodney W. Grimes.Bl -tag -width indent-two
73c7c5d8e3SPhilip Paeps.It Fl -libxo
74c7c5d8e3SPhilip PaepsGenerate output via
75c7c5d8e3SPhilip Paeps.Xr libxo 3
76c7c5d8e3SPhilip Paepsin a selection of different human and machine readable formats.
77c7c5d8e3SPhilip PaepsSee
78c7c5d8e3SPhilip Paeps.Xr xo_parse_args 3
79c7c5d8e3SPhilip Paepsfor details on command line arguments.
808a242856SDima Dorfman.It Fl d Ar date
818a242856SDima DorfmanSpecify the snapshot date and time.
828a242856SDima DorfmanAll users logged in at the snapshot date and time will
838a242856SDima Dorfmanbe reported.
848a242856SDima DorfmanThis may be used with the
858a242856SDima Dorfman.Fl f
8653aa54b8SPhilippe Charnieroption to derive the results from stored
870806dd92SEd Schouten.Pa utx.log
8853aa54b8SPhilippe Charnierfiles.
898a242856SDima DorfmanWhen this argument is provided, all other options except for
908a242856SDima Dorfman.Fl f
918a242856SDima Dorfmanand
92b28e0896STim J. Robbins.Fl n
938a242856SDima Dorfmanare ignored.
948a242856SDima DorfmanThe argument should be in the form
958a242856SDima Dorfman.Sm off
968a242856SDima Dorfman.Op Oo Ar CC Oc Ar YY
978a242856SDima Dorfman.Op Ar MM DD
988a242856SDima Dorfman.Ar hh mm
998a242856SDima Dorfman.Op Ar .SS
1008a242856SDima Dorfman.Sm on
1018a242856SDima Dorfmanwhere each pair of letters represents the following:
1028a242856SDima Dorfman.Pp
1038a242856SDima Dorfman.Bl -tag -width Ds -compact -offset indent
1048a242856SDima Dorfman.It Ar CC
1058a242856SDima DorfmanThe first two digits of the year (the century).
1068a242856SDima Dorfman.It Ar YY
1078a242856SDima DorfmanThe second two digits of the year.
1088a242856SDima DorfmanIf
1098a242856SDima Dorfman.Ar YY
1108a242856SDima Dorfmanis specified, but
1118a242856SDima Dorfman.Ar CC
1128a242856SDima Dorfmanis not, a value for
1138a242856SDima Dorfman.Ar YY
1148a242856SDima Dorfmanbetween 69 and 99 results in a
1158a242856SDima Dorfman.Ar CC
1168a242856SDima Dorfmanvalue of 19.
1178a242856SDima DorfmanOtherwise, a
1188a242856SDima Dorfman.Ar CC
1198a242856SDima Dorfmanvalue of 20 is used.
1208a242856SDima Dorfman.It Ar MM
1218a242856SDima DorfmanMonth of the year, from 1 to 12.
1228a242856SDima Dorfman.It Ar DD
1238a242856SDima DorfmanDay of the month, from 1 to 31.
1248a242856SDima Dorfman.It Ar hh
1258a242856SDima DorfmanHour of the day, from 0 to 23.
1268a242856SDima Dorfman.It Ar mm
1278a242856SDima DorfmanMinute of the hour, from 0 to 59.
1288a242856SDima Dorfman.It Ar SS
1293181398bSConrad MeyerSecond of the minute, from 0 to 60.
1308a242856SDima Dorfman.El
1318a242856SDima Dorfman.Pp
1328a242856SDima DorfmanIf the
1338a242856SDima Dorfman.Ar CC
1348a242856SDima Dorfmanand
1358a242856SDima Dorfman.Ar YY
1368a242856SDima Dorfmanletter pairs are not specified, the values default to the current
1378a242856SDima Dorfmanyear.
1388a242856SDima DorfmanIf the
1398a242856SDima Dorfman.Ar SS
1408a242856SDima Dorfmanletter pair is not specified, the value defaults to 0.
1419b50d902SRodney W. Grimes.It Fl f Ar file
142e8937ba0SPhilippe CharnierRead the file
1439b50d902SRodney W. Grimes.Ar file
1449b50d902SRodney W. Grimesinstead of the default,
1450806dd92SEd Schouten.Pa /var/log/utx.log .
146e72acbbaSDaniel O'Callaghan.It Fl h Ar host
147e72acbbaSDaniel O'Callaghan.Ar Host
148e72acbbaSDaniel O'Callaghannames may be names or internet numbers.
149b28e0896STim J. Robbins.It Fl n Ar maxrec
150b28e0896STim J. RobbinsLimit the report to
151b28e0896STim J. Robbins.Ar maxrec
152b28e0896STim J. Robbinslines.
153e72acbbaSDaniel O'Callaghan.It Fl s
154e72acbbaSDaniel O'CallaghanReport the duration of the login session in seconds, instead of the
155e72acbbaSDaniel O'Callaghandefault days, hours and minutes.
1569b50d902SRodney W. Grimes.It Fl t Ar tty
1579b50d902SRodney W. GrimesSpecify the
1589b50d902SRodney W. Grimes.Ar tty .
1599b50d902SRodney W. GrimesTty names may be given fully or abbreviated, for example,
1609b50d902SRodney W. Grimes.Dq Li "last -t 03"
1619b50d902SRodney W. Grimesis
1629b50d902SRodney W. Grimesequivalent to
1639b50d902SRodney W. Grimes.Dq Li "last -t tty03" .
164e72acbbaSDaniel O'Callaghan.It Fl w
165e72acbbaSDaniel O'CallaghanWiden the duration field to show seconds, as well as the
166e72acbbaSDaniel O'Callaghandefault days, hours and minutes.
167139db33fSIan Dowse.It Fl y
168139db33fSIan DowseReport the year in the session start time.
1699b50d902SRodney W. Grimes.El
1709b50d902SRodney W. Grimes.Pp
1718a242856SDima DorfmanIf multiple arguments are given,
1728a242856SDima Dorfmanand a snapshot time is not specified,
1738a242856SDima Dorfmanthe information which applies to any of the
1749b50d902SRodney W. Grimesarguments is printed, e.g.,
1759b50d902SRodney W. Grimes.Dq Li "last root -t console"
1769b50d902SRodney W. Grimeswould list all of
1779b50d902SRodney W. Grimes.Dq Li root Ns 's
17887faa07bSSheldon Hearnsessions as well as all sessions on the console terminal.
17987faa07bSSheldon HearnIf no
1809b50d902SRodney W. Grimesusers, hostnames or terminals are specified,
1818fe908efSRuslan Ermilov.Nm
1829b50d902SRodney W. Grimesprints a record of
1839b50d902SRodney W. Grimesall logins and logouts.
1849b50d902SRodney W. Grimes.Pp
1859b50d902SRodney W. GrimesThe pseudo-user
1869b50d902SRodney W. Grimes.Ar reboot
1879b50d902SRodney W. Grimeslogs in at reboots of the system, thus
1889b50d902SRodney W. Grimes.Dq Li last reboot
1899b50d902SRodney W. Grimeswill give an indication of mean time between reboot.
1909b50d902SRodney W. Grimes.Pp
1919b50d902SRodney W. GrimesIf
1928fe908efSRuslan Ermilov.Nm
1939b50d902SRodney W. Grimesis interrupted, it indicates to what date the search has
194ea0aee12SDima Dorfmanprogressed.
195ea0aee12SDima DorfmanIf interrupted with a quit signal
1968fe908efSRuslan Ermilov.Nm
1979b50d902SRodney W. Grimesindicates how
1989b50d902SRodney W. Grimesfar the search has progressed and then continues.
1999b50d902SRodney W. Grimes.Sh FILES
2000806dd92SEd Schouten.Bl -tag -width /var/log/utx.log -compact
2010806dd92SEd Schouten.It Pa /var/log/utx.log
2029b50d902SRodney W. Grimeslogin data base
2039b50d902SRodney W. Grimes.El
204*53c8d224SFernando Apesteguía.Sh EXAMPLES
205*53c8d224SFernando ApesteguíaShow logins in pts/14 with the duration in seconds and limit the report to
206*53c8d224SFernando Apesteguíatwo lines:
207*53c8d224SFernando Apesteguía.Bd -literal -offset indent
208*53c8d224SFernando Apesteguía$ last -n2 -s -t pts/14
209*53c8d224SFernando Apesteguíabob    pts/1   Wed Dec  9 11:08   still logged in
210*53c8d224SFernando Apesteguíabob    pts/2   Mon Dec  7 20:10 - 20:23  (     776)
211*53c8d224SFernando Apesteguía.Ed
212*53c8d224SFernando Apesteguía.Pp
213*53c8d224SFernando ApesteguíaShow active logins at
214*53c8d224SFernando Apesteguía.Ql December 7th 20:23
215*53c8d224SFernando Apesteguíaof the current year:
216*53c8d224SFernando Apesteguía.Bd -literal -offset indent
217*53c8d224SFernando Apesteguía$ last -d 12072023
218*53c8d224SFernando Apesteguíabob    pts/1    Mon Dec  7 20:10 - 20:23  (00:12)
219*53c8d224SFernando Apesteguíabob    pts/6    Mon Dec  7 19:24 - 22:27  (03:03)
220*53c8d224SFernando Apesteguíaalice  ttyv0    Mon Dec  7 19:18 - 22:27  (03:09)
221*53c8d224SFernando Apesteguía.Ed
2229b50d902SRodney W. Grimes.Sh SEE ALSO
2239b50d902SRodney W. Grimes.Xr lastcomm 1 ,
2240806dd92SEd Schouten.Xr getutxent 3 ,
225c7c5d8e3SPhilip Paeps.Xr libxo 3 ,
226*53c8d224SFernando Apesteguía.Xr xo_parse_args 3 ,
227*53c8d224SFernando Apesteguía.Xr ac 8 ,
228*53c8d224SFernando Apesteguía.Xr lastlogin 8
2296c7216dfSRuslan Ermilov.Sh HISTORY
2306c7216dfSRuslan Ermilov.Nm
231490f4369SBaptiste Daroussinutility first appeared in
232490f4369SBaptiste Daroussin.Bx 1 .
233490f4369SBaptiste Daroussin.Sh AUTHORS
234490f4369SBaptiste Daroussin.An -nosplit
235490f4369SBaptiste DaroussinThe original version was written by
236490f4369SBaptiste Daroussin.An Howard P. Katseff ;
237490f4369SBaptiste Daroussin.An Keith Bostic
238490f4369SBaptiste Daroussinrewrote it in 1986/87 to add functionality and to improve code quality.
239c7c5d8e3SPhilip Paeps.An Philip Paeps
240c7c5d8e3SPhilip Paepsadded
241c7c5d8e3SPhilip Paeps.Xr libxo 3
242c7c5d8e3SPhilip Paepssupport in August 2018.
243c83d3f45SDavid Greenman.Sh BUGS
244c83d3f45SDavid GreenmanIf a login shell should terminate abnormally for some reason, it is likely
2450227791bSRuslan Ermilovthat a logout record will not be written to the
2460806dd92SEd Schouten.Pa utx.log
24753aa54b8SPhilippe Charnierfile.
24887faa07bSSheldon HearnIn this case,
2498fe908efSRuslan Ermilov.Nm
250c83d3f45SDavid Greenmanwill indicate the logout time as "shutdown".
251