gno/usr.man/man5/utmp.5
1997-09-19 15:47:55 +00:00

215 lines
5.1 KiB
Groff

.\" 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
.\"
.TH UTMP 5 "17 September 1997" GNO "File Formats"
.SH NAME
.BR utmp ,
.BR wtmp ,
.BR lastlog
\- login records
.SH SYNOPSIS
#include <utmp.h>
.SH DESCRIPTION
The file
.BR <utmp.h>
declares the structures used to record information about current
users in the file
.BR utmp ,
logins and logouts in the file
.BR wtmp ,
and last logins in the file
.BR lastlog .
The time stamps of date changes, shutdowns and reboots are also logged in
the
.BR wtmp
file.
.LP
These files can grow rapidly on busy systems, daily or weekly rotation
is recommended.
If any of these files do not exist, it is not created.
These
files must be created manually and are normally maintained in either the script
.BR /etc/daily
or the script
.BR /etc/weekly .
(See
.BR cron (8).)
.nf
#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];
long ut_time;
};
.fi
.LP
Each time a user logs in, the
.BR login
program looks up the user's
.I UID
in the file
.BR lastlog.
If it is found, the timestamp of the last time the user logged
in, the terminal line and the hostname
are written to the standard output. (Providing the login is not
.IR quiet ,
see
.BR login (1).)
The
.BR login
program then records the new login time in the file
.BR lastlog .
.LP
After the new
.I lastlog
record is written,
the file
.BR utmp
is opened and the
.I utmp
record for the user inserted.
This record remains there until
the user logs out at which time it is deleted.
The
.BR utmp
file is used by the programs
.BR rwho (1),
.BR users (1),
.BR w (1),
and
.BR who (1).
.LP
Next, the
.BR login
program opens the file
.BR wtmp ,
and appends the user's
.I utmp
record.
The same
.I utmp
record, with an updated time stamp is later appended
to the file when the user logs out. (See
.BR init (8).)
The
.BR wtmp
file is used by the programs
.BR last (1)
and
.BR ac (8).
.LP
In the event of a date change, a shutdown or reboot, the
following items are logged in the
.BR wtmp
file.
.LP
.RS
.IP "\fBreboot\fR, \fBshutdown\fR"
A system reboot or shutdown has been initiated.
The character
.BR \&~
is placed in the field
.IR ut_line ,
and
.B reboot
or
.B shutdown
in the field
.IR ut_name .
(See
.BR shutdown (8)
and
.BR reboot (8).)
.LP
.IP \fBdate\fR
The system time has been manually or automatically updated.
(See
.BR date (1).)
The command name
.BR date
is recorded in the field
.IR ut_name .
In the field
.IR ut_line ,
the character
.BR \\*(Ba
indicates the time prior to the change, and the character
.BR \&{
indicates the new time.
.RE
.SH FILES
.RS
.IP \fB/var/run/utmp\fR
The
.BR utmp file.
.IP \fB/var/log/wtmp\fR
The
.BR wtmp file.
.IP \fB/var/log/lastlog\fR
The
.BR lastlog file.
.RE
.SH BUGS
This man page is not quite right for the GNO implementation (the structures
are incorrect, as is the utmp path).
.SH SEE ALSO
.BR last (1),
.BR login (1),
.BR who (1),
.BR ac (8),
.BR init (8)
.SH HISTORY
A
.BR utmp
and
.BR wtmp
file format appeared in v6.
The
.BR lastlog
file format appeared in 3.0BSD.