xref: /freebsd/usr.bin/last/last.1 (revision c17d43407fe04133a94055b0dbc7ea8965654a9f)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)last.1	8.1 (Berkeley) 6/6/93
33.\" $FreeBSD$
34.\"
35.Dd March 1, 2002
36.Dt LAST 1
37.Os
38.Sh NAME
39.Nm last
40.Nd indicate last logins of users and ttys
41.Sh SYNOPSIS
42.Nm
43.Op Fl Ns Ar n
44.Op Fl y
45.Oo
46.Fl d
47.Sm off
48.Op Oo Ar CC Oc Ar YY
49.Op Ar MM DD
50.Ar hh mm
51.Op Ar .SS
52.Sm on
53.Oc
54.Op Fl f Ar file
55.Op Fl h Ar host
56.Op Fl s
57.Op Fl t Ar tty
58.Op Fl w
59.Op Ar user ...
60.Sh DESCRIPTION
61.Nm Last
62will either list the sessions of specified
63.Ar users ,
64.Ar ttys ,
65and
66.Ar hosts ,
67in reverse time order,
68or list the users logged in at a specified date and time.
69Each line of output contains
70the user name, the tty from which the session was conducted, any
71hostname, the start and stop times for the session, and the duration
72of the session.
73If the session is still continuing or was cut short by
74a crash or shutdown,
75.Nm
76will so indicate.
77.Pp
78.Bl -tag -width indent-two
79.It Fl Ar n
80Limits the report to
81.Ar n
82lines.
83.It Fl d Ar date
84Specify the snapshot date and time.
85All users logged in at the snapshot date and time will
86be reported.
87This may be used with the
88.Fl f
89option to derive the results from stored wtmp files.
90When this argument is provided, all other options except for
91.Fl f
92and
93.Fl Ar n
94are ignored.
95The argument should be in the form
96.Sm off
97.Op Oo Ar CC Oc Ar YY
98.Op Ar MM DD
99.Ar hh mm
100.Op Ar .SS
101.Sm on
102where each pair of letters represents the following:
103.Pp
104.Bl -tag -width Ds -compact -offset indent
105.It Ar CC
106The first two digits of the year (the century).
107.It Ar YY
108The second two digits of the year.
109If
110.Ar YY
111is specified, but
112.Ar CC
113is not, a value for
114.Ar YY
115between 69 and 99 results in a
116.Ar CC
117value of 19.
118Otherwise, a
119.Ar CC
120value of 20 is used.
121.It Ar MM
122Month of the year, from 1 to 12.
123.It Ar DD
124Day of the month, from 1 to 31.
125.It Ar hh
126Hour of the day, from 0 to 23.
127.It Ar mm
128Minute of the hour, from 0 to 59.
129.It Ar SS
130Second of the minute, from 0 to 61.
131.El
132.Pp
133If the
134.Ar CC
135and
136.Ar YY
137letter pairs are not specified, the values default to the current
138year.
139If the
140.Ar SS
141letter pair is not specified, the value defaults to 0.
142.It Fl f Ar file
143.Nm Last
144reads the file
145.Ar file
146instead of the default,
147.Pa /var/log/wtmp .
148.It Fl h Ar host
149.Ar Host
150names may be names or internet numbers.
151.It Fl s
152Report the duration of the login session in seconds, instead of the
153default days, hours and minutes.
154.It Fl t Ar tty
155Specify the
156.Ar tty .
157Tty names may be given fully or abbreviated, for example,
158.Dq Li "last -t 03"
159is
160equivalent to
161.Dq Li "last -t tty03" .
162.It Fl w
163Widen the duration field to show seconds, as well as the
164default days, hours and minutes.
165.It Fl y
166Report the year in the session start time.
167.El
168.Pp
169If multiple arguments are given,
170and a snapshot time is not specified,
171the information which applies to any of the
172arguments is printed, e.g.,
173.Dq Li "last root -t console"
174would list all of
175.Dq Li root Ns 's
176sessions as well as all sessions on the console terminal.
177If no
178users, hostnames or terminals are specified,
179.Nm
180prints a record of
181all logins and logouts.
182.Pp
183The pseudo-user
184.Ar reboot
185logs in at reboots of the system, thus
186.Dq Li last reboot
187will give an indication of mean time between reboot.
188.Pp
189If
190.Nm
191is interrupted, it indicates to what date the search has
192progressed.
193If interrupted with a quit signal
194.Nm
195indicates how
196far the search has progressed and then continues.
197.Sh FILES
198.Bl -tag -width /var/log/wtmp -compact
199.It Pa /var/log/wtmp
200login data base
201.El
202.Sh SEE ALSO
203.Xr lastcomm 1 ,
204.Xr utmp 5 ,
205.Xr ac 8
206.Sh BUGS
207If a login shell should terminate abnormally for some reason, it is likely
208that a logout record won't be written to the wtmp file.
209In this case,
210.Nm
211will indicate the logout time as "shutdown".
212.Sh HISTORY
213.Nm Last
214appeared in
215.Bx 3.0 .
216