xref: /freebsd/usr.bin/last/last.1 (revision 39beb93c)
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 July 27, 2003
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 swy
44.Oo
45.Fl d
46.Sm off
47.Op Oo Ar CC Oc Ar YY
48.Op Ar MM DD
49.Ar hh mm
50.Op Ar .SS
51.Sm on
52.Oc
53.Op Fl f Ar file
54.Op Fl h Ar host
55.Op Fl n Ar maxrec
56.Op Fl t Ar tty
57.Op Ar user ...
58.Sh DESCRIPTION
59The
60.Nm
61utility will either list the sessions of specified
62.Ar users ,
63.Ar ttys ,
64and
65.Ar hosts ,
66in reverse time order,
67or list the users logged in at a specified date and time.
68Each line of output contains
69the user name, the tty from which the session was conducted, any
70hostname, the start and stop times for the session, and the duration
71of the session.
72If the session is still continuing or was cut short by
73a crash or shutdown,
74.Nm
75will so indicate.
76.Pp
77The following options are available:
78.Bl -tag -width indent-two
79.It Fl d Ar date
80Specify the snapshot date and time.
81All users logged in at the snapshot date and time will
82be reported.
83This may be used with the
84.Fl f
85option to derive the results from stored
86.Pa wtmp
87files.
88When this argument is provided, all other options except for
89.Fl f
90and
91.Fl n
92are ignored.
93The argument should be in the form
94.Sm off
95.Op Oo Ar CC Oc Ar YY
96.Op Ar MM DD
97.Ar hh mm
98.Op Ar .SS
99.Sm on
100where each pair of letters represents the following:
101.Pp
102.Bl -tag -width Ds -compact -offset indent
103.It Ar CC
104The first two digits of the year (the century).
105.It Ar YY
106The second two digits of the year.
107If
108.Ar YY
109is specified, but
110.Ar CC
111is not, a value for
112.Ar YY
113between 69 and 99 results in a
114.Ar CC
115value of 19.
116Otherwise, a
117.Ar CC
118value of 20 is used.
119.It Ar MM
120Month of the year, from 1 to 12.
121.It Ar DD
122Day of the month, from 1 to 31.
123.It Ar hh
124Hour of the day, from 0 to 23.
125.It Ar mm
126Minute of the hour, from 0 to 59.
127.It Ar SS
128Second of the minute, from 0 to 61.
129.El
130.Pp
131If the
132.Ar CC
133and
134.Ar YY
135letter pairs are not specified, the values default to the current
136year.
137If the
138.Ar SS
139letter pair is not specified, the value defaults to 0.
140.It Fl f Ar file
141Read the file
142.Ar file
143instead of the default,
144.Pa /var/log/wtmp .
145.It Fl h Ar host
146.Ar Host
147names may be names or internet numbers.
148.It Fl n Ar maxrec
149Limit the report to
150.Ar maxrec
151lines.
152.It Fl s
153Report the duration of the login session in seconds, instead of the
154default days, hours and minutes.
155.It Fl t Ar tty
156Specify the
157.Ar tty .
158Tty names may be given fully or abbreviated, for example,
159.Dq Li "last -t 03"
160is
161equivalent to
162.Dq Li "last -t tty03" .
163.It Fl w
164Widen the duration field to show seconds, as well as the
165default days, hours and minutes.
166.It Fl y
167Report the year in the session start time.
168.El
169.Pp
170If multiple arguments are given,
171and a snapshot time is not specified,
172the information which applies to any of the
173arguments is printed, e.g.,
174.Dq Li "last root -t console"
175would list all of
176.Dq Li root Ns 's
177sessions as well as all sessions on the console terminal.
178If no
179users, hostnames or terminals are specified,
180.Nm
181prints a record of
182all logins and logouts.
183.Pp
184The pseudo-user
185.Ar reboot
186logs in at reboots of the system, thus
187.Dq Li last reboot
188will give an indication of mean time between reboot.
189.Pp
190If
191.Nm
192is interrupted, it indicates to what date the search has
193progressed.
194If interrupted with a quit signal
195.Nm
196indicates how
197far the search has progressed and then continues.
198.Sh FILES
199.Bl -tag -width /var/log/wtmp -compact
200.It Pa /var/log/wtmp
201login data base
202.El
203.Sh SEE ALSO
204.Xr lastcomm 1 ,
205.Xr utmp 5 ,
206.Xr ac 8
207.Sh HISTORY
208A
209.Nm
210utility appeared in
211.Bx 3.0 .
212.Sh BUGS
213If a login shell should terminate abnormally for some reason, it is likely
214that a logout record will not be written to the
215.Pa wtmp
216file.
217In this case,
218.Nm
219will indicate the logout time as "shutdown".
220