1994-05-30 19:09:18 +00:00
|
|
|
.\" Copyright (c) 1980, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)utmp.5 8.2 (Berkeley) 3/17/94
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-30 19:09:18 +00:00
|
|
|
.\"
|
2001-11-21 11:36:23 +00:00
|
|
|
.Dd November 14, 2001
|
1994-05-30 19:09:18 +00:00
|
|
|
.Dt UTMP 5
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm utmp ,
|
|
|
|
.Nm wtmp ,
|
|
|
|
.Nm lastlog
|
|
|
|
.Nd login records
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In utmp.h
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The file
|
|
|
|
.Aq Pa utmp.h
|
|
|
|
declares the structures used to record information about current
|
|
|
|
users in the file
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm ,
|
1994-05-30 19:09:18 +00:00
|
|
|
logins and logouts in the file
|
|
|
|
.Nm wtmp ,
|
|
|
|
and last logins in the file
|
|
|
|
.Nm lastlog .
|
|
|
|
The time stamps of date changes, shutdowns and reboots are also logged in
|
|
|
|
the
|
|
|
|
.Nm wtmp
|
|
|
|
file.
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
#define _PATH_UTMP "/var/run/utmp"
|
|
|
|
#define _PATH_WTMP "/var/log/wtmp"
|
|
|
|
#define _PATH_LASTLOG "/var/log/lastlog"
|
|
|
|
|
1996-12-04 11:31:14 +00:00
|
|
|
#define UT_NAMESIZE 16
|
1994-05-30 19:09:18 +00:00
|
|
|
#define UT_LINESIZE 8
|
|
|
|
#define UT_HOSTSIZE 16
|
|
|
|
|
|
|
|
struct lastlog {
|
2002-10-04 00:25:50 +00:00
|
|
|
int32_t ll_time; /* When user logged in */
|
2001-11-14 05:03:37 +00:00
|
|
|
char ll_line[UT_LINESIZE]; /* Terminal line name */
|
|
|
|
char ll_host[UT_HOSTSIZE]; /* Host user came from */
|
1994-05-30 19:09:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct utmp {
|
2001-11-14 05:03:37 +00:00
|
|
|
char ut_line[UT_LINESIZE]; /* Terminal line name */
|
|
|
|
char ut_name[UT_NAMESIZE]; /* User's login name */
|
|
|
|
char ut_host[UT_HOSTSIZE]; /* Host user came from */
|
2002-10-04 00:25:50 +00:00
|
|
|
int32_t ut_time; /* When user logged in */
|
1994-05-30 19:09:18 +00:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2001-11-14 05:03:37 +00:00
|
|
|
The
|
|
|
|
.Nm lastlog
|
|
|
|
file is a linear array of
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt lastlog
|
2001-11-14 05:03:37 +00:00
|
|
|
structures indexed by a user's
|
|
|
|
.Tn UID .
|
|
|
|
The
|
2001-11-21 11:36:23 +00:00
|
|
|
.Nm
|
2001-11-14 05:03:37 +00:00
|
|
|
file is a linear array of
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt utmp
|
2001-11-14 05:03:37 +00:00
|
|
|
structures indexed by a terminal line number
|
|
|
|
(see
|
|
|
|
.Xr ttyslot 3 ) .
|
|
|
|
The
|
|
|
|
.Nm wtmp
|
|
|
|
file consists of
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt utmp
|
2001-11-14 05:03:37 +00:00
|
|
|
structures and is a binary log file,
|
|
|
|
that is, grows linearly at its end.
|
|
|
|
.Pp
|
1994-05-30 19:09:18 +00:00
|
|
|
Each time a user logs in, the
|
1996-04-08 04:18:31 +00:00
|
|
|
.Xr login 1
|
1994-05-30 19:09:18 +00:00
|
|
|
program looks up the user's
|
|
|
|
.Tn UID
|
|
|
|
in the file
|
2001-02-01 16:38:02 +00:00
|
|
|
.Nm lastlog .
|
1994-05-30 19:09:18 +00:00
|
|
|
If it is found, the timestamp of the last time the user logged
|
|
|
|
in, the terminal line and the hostname
|
1998-06-28 21:33:42 +00:00
|
|
|
are written to the standard output (unless the login is
|
1994-05-30 19:09:18 +00:00
|
|
|
.Em quiet ,
|
|
|
|
see
|
1998-06-28 21:33:42 +00:00
|
|
|
.Xr login 1 ) .
|
1994-05-30 19:09:18 +00:00
|
|
|
The
|
2001-11-21 11:36:23 +00:00
|
|
|
.Xr login 1
|
1994-05-30 19:09:18 +00:00
|
|
|
program then records the new login time in the file
|
|
|
|
.Nm lastlog .
|
|
|
|
.Pp
|
|
|
|
After the new
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt lastlog
|
1998-06-28 21:33:42 +00:00
|
|
|
record is written,
|
1994-05-30 19:09:18 +00:00
|
|
|
.\" the
|
|
|
|
.\" .Xr libutil 3
|
|
|
|
.\" routine
|
|
|
|
the file
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1994-05-30 19:09:18 +00:00
|
|
|
is opened and the
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt utmp
|
|
|
|
record for the user is inserted.
|
1994-05-30 19:09:18 +00:00
|
|
|
This record remains there until
|
|
|
|
the user logs out at which time it is deleted.
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1994-05-30 19:09:18 +00:00
|
|
|
file is used by the programs
|
|
|
|
.Xr rwho 1 ,
|
|
|
|
.Xr users 1 ,
|
|
|
|
.Xr w 1 ,
|
|
|
|
and
|
|
|
|
.Xr who 1 .
|
|
|
|
.Pp
|
|
|
|
Next, the
|
2001-10-11 11:29:37 +00:00
|
|
|
.Xr login 1
|
1994-05-30 19:09:18 +00:00
|
|
|
program opens the file
|
|
|
|
.Nm wtmp ,
|
|
|
|
and appends the user's
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt utmp
|
1994-05-30 19:09:18 +00:00
|
|
|
record.
|
2001-11-14 05:03:37 +00:00
|
|
|
The user's subsequent logout from the terminal
|
|
|
|
line is marked by a special
|
2001-11-21 11:36:23 +00:00
|
|
|
.Vt utmp
|
2001-11-14 05:03:37 +00:00
|
|
|
record with
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_line
|
2001-11-14 05:03:37 +00:00
|
|
|
set accordingly,
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_time
|
2001-11-14 05:03:37 +00:00
|
|
|
updated, but
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_name
|
2001-11-14 05:03:37 +00:00
|
|
|
and
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_host
|
2001-11-14 05:03:37 +00:00
|
|
|
both empty
|
|
|
|
(see
|
1998-06-28 21:33:42 +00:00
|
|
|
.Xr init 8 ) .
|
1994-05-30 19:09:18 +00:00
|
|
|
The
|
|
|
|
.Nm wtmp
|
|
|
|
file is used by the programs
|
|
|
|
.Xr last 1
|
|
|
|
and
|
|
|
|
.Xr ac 8 .
|
|
|
|
.Pp
|
|
|
|
In the event of a date change, a shutdown or reboot, the
|
|
|
|
following items are logged in the
|
|
|
|
.Nm wtmp
|
|
|
|
file.
|
|
|
|
.Pp
|
2001-11-21 11:36:23 +00:00
|
|
|
.Bl -tag -width ".Li shutdown" -compact
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Li reboot
|
|
|
|
.It Li shutdown
|
|
|
|
A system reboot or shutdown has been initiated.
|
|
|
|
The character
|
|
|
|
.Ql \&~
|
|
|
|
is placed in the field
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_line ,
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
|
|
|
.Li reboot
|
|
|
|
or
|
|
|
|
.Li shutdown
|
|
|
|
in the field
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_name
|
1998-06-28 21:33:42 +00:00
|
|
|
(see
|
1994-05-30 19:09:18 +00:00
|
|
|
.Xr shutdown 8
|
|
|
|
and
|
1998-06-28 21:33:42 +00:00
|
|
|
.Xr reboot 8 ) .
|
1994-05-30 19:09:18 +00:00
|
|
|
.Pp
|
|
|
|
.It Li date
|
1998-06-28 21:33:42 +00:00
|
|
|
The system time has been manually or automatically updated
|
|
|
|
(see
|
|
|
|
.Xr date 1 ) .
|
1994-05-30 19:09:18 +00:00
|
|
|
The command name
|
2001-11-21 11:36:23 +00:00
|
|
|
.Li date
|
1994-05-30 19:09:18 +00:00
|
|
|
is recorded in the field
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_name .
|
1994-05-30 19:09:18 +00:00
|
|
|
In the field
|
2001-11-21 11:36:23 +00:00
|
|
|
.Va ut_line ,
|
1994-05-30 19:09:18 +00:00
|
|
|
the character
|
2001-02-01 16:38:02 +00:00
|
|
|
.Ql \&|
|
1994-05-30 19:09:18 +00:00
|
|
|
indicates the time prior to the change, and the character
|
|
|
|
.Ql \&{
|
|
|
|
indicates the new time.
|
|
|
|
.El
|
2001-11-14 05:03:37 +00:00
|
|
|
.Sh NOTES
|
|
|
|
The
|
|
|
|
.Nm wtmp
|
|
|
|
file can grow rapidly on busy systems, so daily or weekly rotation
|
|
|
|
is recommended.
|
|
|
|
It is maintained by
|
|
|
|
.Xr newsyslog 8 .
|
|
|
|
.Pp
|
|
|
|
If any one of these files does not exist, it is not created by
|
|
|
|
.Xr login 1 .
|
|
|
|
They must be created manually.
|
|
|
|
.Pp
|
|
|
|
The supplied
|
|
|
|
.Xr login 3 ,
|
|
|
|
.Xr logout 3 ,
|
|
|
|
and
|
|
|
|
.Xr logwtmp 3
|
|
|
|
utility functions should be used to perform
|
|
|
|
the standard actions on the
|
2001-11-21 11:36:23 +00:00
|
|
|
.Nm
|
2001-11-14 05:03:37 +00:00
|
|
|
and
|
|
|
|
.Nm wtmp
|
|
|
|
files in order to maintain the portability across
|
|
|
|
systems with different formats of those files.
|
1994-05-30 19:09:18 +00:00
|
|
|
.Sh FILES
|
2001-11-21 11:36:23 +00:00
|
|
|
.Bl -tag -width ".Pa /var/log/lastlog" -compact
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Pa /var/run/utmp
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
|
|
|
file.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Pa /var/log/wtmp
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm wtmp
|
|
|
|
file.
|
1994-05-30 19:09:18 +00:00
|
|
|
.It Pa /var/log/lastlog
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm lastlog
|
|
|
|
file.
|
1994-05-30 19:09:18 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr last 1 ,
|
|
|
|
.Xr login 1 ,
|
1998-01-02 19:22:52 +00:00
|
|
|
.Xr w 1 ,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Xr who 1 ,
|
2001-11-14 05:03:37 +00:00
|
|
|
.Xr login 3 ,
|
|
|
|
.Xr logout 3 ,
|
|
|
|
.Xr logwtmp 3 ,
|
|
|
|
.Xr ttyslot 3 ,
|
1994-05-30 19:09:18 +00:00
|
|
|
.Xr ac 8 ,
|
|
|
|
.Xr init 8
|
|
|
|
.Sh HISTORY
|
|
|
|
A
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1994-05-30 19:09:18 +00:00
|
|
|
and
|
|
|
|
.Nm wtmp
|
|
|
|
file format appeared in
|
|
|
|
.At v6 .
|
|
|
|
The
|
|
|
|
.Nm lastlog
|
|
|
|
file format appeared in
|
|
|
|
.Bx 3.0 .
|