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. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)last.1 8.1 (Berkeley) 6/6/93 29.\" $FreeBSD$ 30.\" 31.Dd August 28, 2018 32.Dt LAST 1 33.Os 34.Sh NAME 35.Nm last 36.Nd indicate last logins of users and ttys 37.Sh SYNOPSIS 38.Nm 39.Op Fl -libxo 40.Op Fl swy 41.Oo 42.Fl d 43.Sm off 44.Op Oo Ar CC Oc Ar YY 45.Op Ar MM DD 46.Ar hh mm 47.Op Ar .SS 48.Sm on 49.Oc 50.Op Fl f Ar file 51.Op Fl h Ar host 52.Op Fl n Ar maxrec 53.Op Fl t Ar tty 54.Op Ar user ... 55.Sh DESCRIPTION 56The 57.Nm 58utility will either list the sessions of specified 59.Ar users , 60.Ar ttys , 61and 62.Ar hosts , 63in reverse time order, 64or list the users logged in at a specified date and time. 65Each line of output contains 66the user name, the tty from which the session was conducted, any 67hostname, the start and stop times for the session, and the duration 68of the session. 69If the session is still continuing or was cut short by 70a crash or shutdown, 71.Nm 72will so indicate. 73.Pp 74The following options are available: 75.Bl -tag -width indent-two 76.It Fl -libxo 77Generate output via 78.Xr libxo 3 79in a selection of different human and machine readable formats. 80See 81.Xr xo_parse_args 3 82for details on command line arguments. 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 90.Pa utx.log 91files. 92When this argument is provided, all other options except for 93.Fl f 94and 95.Fl n 96are ignored. 97The argument should be in the form 98.Sm off 99.Op Oo Ar CC Oc Ar YY 100.Op Ar MM DD 101.Ar hh mm 102.Op Ar .SS 103.Sm on 104where each pair of letters represents the following: 105.Pp 106.Bl -tag -width Ds -compact -offset indent 107.It Ar CC 108The first two digits of the year (the century). 109.It Ar YY 110The second two digits of the year. 111If 112.Ar YY 113is specified, but 114.Ar CC 115is not, a value for 116.Ar YY 117between 69 and 99 results in a 118.Ar CC 119value of 19. 120Otherwise, a 121.Ar CC 122value of 20 is used. 123.It Ar MM 124Month of the year, from 1 to 12. 125.It Ar DD 126Day of the month, from 1 to 31. 127.It Ar hh 128Hour of the day, from 0 to 23. 129.It Ar mm 130Minute of the hour, from 0 to 59. 131.It Ar SS 132Second of the minute, from 0 to 60. 133.El 134.Pp 135If the 136.Ar CC 137and 138.Ar YY 139letter pairs are not specified, the values default to the current 140year. 141If the 142.Ar SS 143letter pair is not specified, the value defaults to 0. 144.It Fl f Ar file 145Read the file 146.Ar file 147instead of the default, 148.Pa /var/log/utx.log . 149.It Fl h Ar host 150.Ar Host 151names may be names or internet numbers. 152.It Fl n Ar maxrec 153Limit the report to 154.Ar maxrec 155lines. 156.It Fl s 157Report the duration of the login session in seconds, instead of the 158default days, hours and minutes. 159.It Fl t Ar tty 160Specify the 161.Ar tty . 162Tty names may be given fully or abbreviated, for example, 163.Dq Li "last -t 03" 164is 165equivalent to 166.Dq Li "last -t tty03" . 167.It Fl w 168Widen the duration field to show seconds, as well as the 169default days, hours and minutes. 170.It Fl y 171Report the year in the session start time. 172.El 173.Pp 174If multiple arguments are given, 175and a snapshot time is not specified, 176the information which applies to any of the 177arguments is printed, e.g., 178.Dq Li "last root -t console" 179would list all of 180.Dq Li root Ns 's 181sessions as well as all sessions on the console terminal. 182If no 183users, hostnames or terminals are specified, 184.Nm 185prints a record of 186all logins and logouts. 187.Pp 188The pseudo-user 189.Ar reboot 190logs in at reboots of the system, thus 191.Dq Li last reboot 192will give an indication of mean time between reboot. 193.Pp 194If 195.Nm 196is interrupted, it indicates to what date the search has 197progressed. 198If interrupted with a quit signal 199.Nm 200indicates how 201far the search has progressed and then continues. 202.Sh FILES 203.Bl -tag -width /var/log/utx.log -compact 204.It Pa /var/log/utx.log 205login data base 206.El 207.Sh SEE ALSO 208.Xr lastcomm 1 , 209.Xr getutxent 3 , 210.Xr ac 8 , 211.Xr lastlogin 8 , 212.Xr libxo 3 , 213.Xr xo_parse_args 3 214.Sh HISTORY 215.Nm 216utility first appeared in 217.Bx 1 . 218.Sh AUTHORS 219.An -nosplit 220The original version was written by 221.An Howard P. Katseff ; 222.An Keith Bostic 223rewrote it in 1986/87 to add functionality and to improve code quality. 224.An Philip Paeps 225added 226.Xr libxo 3 227support in August 2018. 228.Sh BUGS 229If a login shell should terminate abnormally for some reason, it is likely 230that a logout record will not be written to the 231.Pa utx.log 232file. 233In this case, 234.Nm 235will indicate the logout time as "shutdown". 236