1998-04-29 15:33:55 +04:00
|
|
|
.\" $NetBSD: utmp.5,v 1.8 1998/04/29 11:33:58 fair Exp $
|
1994-11-30 22:31:07 +03:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1980, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
1994-11-30 22:31:07 +03:00
|
|
|
.\" @(#)utmp.5 8.2 (Berkeley) 3/17/94
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
1994-11-30 22:31:07 +03:00
|
|
|
.Dd March 17, 1994
|
1993-03-21 12:45:37 +03:00
|
|
|
.Dt UTMP 5
|
|
|
|
.Os BSD 4
|
|
|
|
.Sh NAME
|
|
|
|
.Nm utmp ,
|
|
|
|
.Nm wtmp ,
|
|
|
|
.Nm lastlog
|
|
|
|
.Nd login records
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Fd #include <utmp.h>
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The file
|
|
|
|
.Aq Pa utmp.h
|
|
|
|
declares the structures used to record information about current
|
|
|
|
users in the file
|
|
|
|
.Nm utmp ,
|
|
|
|
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.
|
|
|
|
.Pp
|
1997-10-08 17:47:18 +04:00
|
|
|
The
|
|
|
|
.Nm wtmp
|
|
|
|
file can grow rapidly on busy systems, and is normally rotated with
|
|
|
|
.Xr newsyslog 8 .
|
|
|
|
.Pp
|
|
|
|
These files must be created manually;
|
|
|
|
if they do not exist, they are not created automatically.
|
1993-03-21 12:45:37 +03:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
#define _PATH_UTMP "/var/run/utmp"
|
|
|
|
#define _PATH_WTMP "/var/log/wtmp"
|
|
|
|
#define _PATH_LASTLOG "/var/log/lastlog"
|
|
|
|
|
|
|
|
#define UT_NAMESIZE 8
|
|
|
|
#define UT_LINESIZE 8
|
|
|
|
#define UT_HOSTSIZE 16
|
|
|
|
|
|
|
|
struct lastlog {
|
|
|
|
time_t ll_time;
|
|
|
|
char ll_line[UT_LINESIZE];
|
|
|
|
char ll_host[UT_HOSTSIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct utmp {
|
|
|
|
char ut_line[UT_LINESIZE];
|
|
|
|
char ut_name[UT_NAMESIZE];
|
|
|
|
char ut_host[UT_HOSTSIZE];
|
1994-10-19 07:01:14 +03:00
|
|
|
time_t ut_time;
|
1993-03-21 12:45:37 +03:00
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Each time a user logs in, the
|
1998-04-29 15:33:55 +04:00
|
|
|
.Xr login 1
|
1993-03-21 12:45:37 +03:00
|
|
|
program looks up the user's
|
|
|
|
.Tn UID
|
|
|
|
in the file
|
1997-06-22 12:11:08 +04:00
|
|
|
.Nm lastlog .
|
1993-03-21 12:45:37 +03:00
|
|
|
If it is found, the timestamp of the last time the user logged
|
|
|
|
in, the terminal line and the hostname
|
1998-04-29 15:33:55 +04:00
|
|
|
are written to the standard output, providing the login is not set
|
|
|
|
.Em quiet ;
|
1993-03-21 12:45:37 +03:00
|
|
|
see
|
1998-04-29 15:33:55 +04:00
|
|
|
.Xr login 1 .
|
1993-03-21 12:45:37 +03:00
|
|
|
The
|
1998-04-29 15:33:55 +04:00
|
|
|
.Xr login 1
|
1993-03-21 12:45:37 +03:00
|
|
|
program then records the new login time in the file
|
|
|
|
.Nm lastlog .
|
|
|
|
.Pp
|
|
|
|
After the new
|
|
|
|
.Fa lastlog
|
|
|
|
record is written ,
|
|
|
|
.\" the
|
|
|
|
.\" .Xr libutil 3
|
|
|
|
.\" routine
|
|
|
|
the file
|
|
|
|
.Nm utmp
|
|
|
|
is opened and the
|
|
|
|
.Fa utmp
|
|
|
|
record for the user inserted.
|
|
|
|
This record remains there until
|
1997-06-22 12:11:08 +04:00
|
|
|
the user logs out at which time it is deleted (by clearing
|
|
|
|
the user and host fields, and updating the timestamp field).
|
1993-03-21 12:45:37 +03:00
|
|
|
The
|
|
|
|
.Nm utmp
|
|
|
|
file is used by the programs
|
|
|
|
.Xr rwho 1 ,
|
|
|
|
.Xr users 1 ,
|
|
|
|
.Xr w 1 ,
|
|
|
|
and
|
|
|
|
.Xr who 1 .
|
|
|
|
.Pp
|
|
|
|
Next, the
|
1998-04-29 15:33:55 +04:00
|
|
|
.Xr login 1
|
1993-03-21 12:45:37 +03:00
|
|
|
program opens the file
|
|
|
|
.Nm wtmp ,
|
|
|
|
and appends the user's
|
|
|
|
.Fa utmp
|
|
|
|
record.
|
1997-06-22 12:11:08 +04:00
|
|
|
When the user logs out, a
|
1993-03-21 12:45:37 +03:00
|
|
|
.Fa utmp
|
1997-06-22 12:11:08 +04:00
|
|
|
record with the tty line, an updated time stamp, and cleared user and host
|
1998-04-29 15:33:55 +04:00
|
|
|
fields is appended to the file by
|
|
|
|
.Xr init 8 .
|
1993-03-21 12:45:37 +03: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
|
|
|
|
.Bl -tag -width shutdownxx -compact
|
|
|
|
.It Li reboot
|
|
|
|
.It Li shutdown
|
|
|
|
A system reboot or shutdown has been initiated.
|
|
|
|
The character
|
|
|
|
.Ql \&~
|
|
|
|
is placed in the field
|
|
|
|
.Fa ut_line ,
|
|
|
|
and
|
|
|
|
.Li reboot
|
|
|
|
or
|
|
|
|
.Li shutdown
|
|
|
|
in the field
|
1998-04-29 15:33:55 +04:00
|
|
|
.Fa ut_name
|
|
|
|
(see
|
1993-03-21 12:45:37 +03:00
|
|
|
.Xr shutdown 8
|
|
|
|
and
|
1998-04-29 15:33:55 +04:00
|
|
|
.Xr reboot 8 ) .
|
1993-03-21 12:45:37 +03:00
|
|
|
.Pp
|
|
|
|
.It Li date
|
1998-04-29 15:33:55 +04:00
|
|
|
The system time has been manually or automatically updated by
|
|
|
|
.Xr date 1 .
|
1993-03-21 12:45:37 +03:00
|
|
|
The command name
|
1998-04-29 15:33:55 +04:00
|
|
|
.Em date
|
1993-03-21 12:45:37 +03:00
|
|
|
is recorded in the field
|
|
|
|
.Fa ut_name .
|
|
|
|
In the field
|
|
|
|
.Fa ut_line ,
|
|
|
|
the character
|
|
|
|
.Ql \\*(Ba
|
1994-03-10 01:49:38 +03:00
|
|
|
indicates the time prior to the change, and the character
|
|
|
|
.Ql \&{
|
1993-03-21 12:45:37 +03:00
|
|
|
indicates the new time.
|
|
|
|
.El
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width /var/log/lastlog -compact
|
|
|
|
.It Pa /var/run/utmp
|
|
|
|
The
|
1997-06-22 12:11:08 +04:00
|
|
|
.Nm utmp
|
|
|
|
file.
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Pa /var/log/wtmp
|
|
|
|
The
|
1997-06-22 12:11:08 +04:00
|
|
|
.Nm wtmp
|
|
|
|
file.
|
1993-03-21 12:45:37 +03:00
|
|
|
.It Pa /var/log/lastlog
|
|
|
|
The
|
1997-06-22 12:11:08 +04:00
|
|
|
.Nm lastlog
|
|
|
|
file.
|
1993-03-21 12:45:37 +03:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr last 1 ,
|
|
|
|
.Xr login 1 ,
|
|
|
|
.Xr who 1 ,
|
|
|
|
.Xr ac 8 ,
|
1997-10-08 17:47:18 +04:00
|
|
|
.Xr init 8 ,
|
|
|
|
.Xr newsyslog 8
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
|
|
|
.Nm utmp
|
|
|
|
and
|
|
|
|
.Nm wtmp
|
|
|
|
file format appeared in
|
|
|
|
.At v6 .
|
|
|
|
The
|
|
|
|
.Nm lastlog
|
|
|
|
file format appeared in
|
|
|
|
.Bx 3.0 .
|