xref: /csrg-svn/share/man/man5/utmp.5 (revision 49204)
1*49204Scael.\" Copyright (c) 1980, 1991 Regents of the University of California.
248833Scael.\" All rights reserved.
320770Smckusick.\"
4*49204Scael.\" %sccs.include.redist.roff%
520770Smckusick.\"
6*49204Scael.\"     @(#)utmp.5	6.8 (Berkeley) 05/05/91
748833Scael.\"
8*49204Scael.Dd
9*49204Scael.Dt UTMP 5
10*49204Scael.Os BSD 4
11*49204Scael.Sh NAME
12*49204Scael.Nm utmp ,
13*49204Scael.Nm wtmp ,
14*49204Scael.Nm lastlog
15*49204Scael.Nd login records
16*49204Scael.Sh SYNOPSIS
17*49204Scael.Fd #include <utmp.h>
18*49204Scael.Sh DESCRIPTION
19*49204ScaelThe file
20*49204Scael.Aq Pa utmp.h
21*49204Scaeldeclares the structures used to record information about current
22*49204Scaelusers in the file
23*49204Scael.Nm utmp ,
24*49204Scaellogins and logouts in the file
25*49204Scael.Nm wtmp ,
26*49204Scaeland last logins in the file
27*49204Scael.Nm lastlog .
28*49204ScaelThe time stamps of date changes, shutdowns and reboots are also logged in
29*49204Scaelthe
30*49204Scael.Nm wtmp
31*49204Scaelfile.
32*49204Scael.Pp
33*49204ScaelThese files can grow rapidly on busy systems, daily or weekly rotation
34*49204Scaelis recommended.
35*49204ScaelIf any of these files do not exist, it is not created.
36*49204ScaelThese
37*49204Scaelfiles must be created manually and are normally maintained in either the script
38*49204Scael.Pa /etc/daily
39*49204Scaelor the script
40*49204Scael.Pa /etc/weekly .
41*49204Scael(See
42*49204Scael.Xr cron 8 . )
43*49204Scael.Bd -literal -offset indent
44*49204Scael#define _PATH_UTMP      "/var/run/utmp"
45*49204Scael#define _PATH_WTMP      "/var/log/wtmp"
46*49204Scael#define _PATH_LASTLOG   "/var/log/lastlog"
47*49204Scael
48*49204Scael#define UT_NAMESIZE     8
49*49204Scael#define UT_LINESIZE     8
50*49204Scael#define UT_HOSTSIZE     16
51*49204Scael
52*49204Scaelstruct lastlog {
53*49204Scael        time_t  ll_time;
54*49204Scael        char    ll_line[UT_LINESIZE];
55*49204Scael        char    ll_host[UT_HOSTSIZE];
56*49204Scael};
57*49204Scael
5835603Sbosticstruct utmp {
59*49204Scael        char    ut_line[UT_LINESIZE];
60*49204Scael        char    ut_name[UT_NAMESIZE];
61*49204Scael        char    ut_host[UT_HOSTSIZE];
62*49204Scael        long    ut_time;
6335603Sbostic};
64*49204Scael.Ed
65*49204Scael.Pp
66*49204ScaelEach time a user logs in, the
67*49204Scael.Xr login
68*49204Scaelprogram looks up the user's
69*49204Scael.Tn UID
70*49204Scaelin the file
71*49204Scael.Nm lastlog.
72*49204ScaelIf it is found, the timestamp of the last time the user logged
73*49204Scaelin, the terminal line and the hostname
74*49204Scaelare written to the standard output. (Providing the login is not
75*49204Scael.Em quiet ,
76*49204Scaelsee
77*49204Scael.Xr login 1 . )
7820770SmckusickThe
79*49204Scael.Xr login
80*49204Scaelprogram then records the new login time in the file
81*49204Scael.Nm lastlog .
82*49204Scael.Pp
83*49204ScaelAfter the new
84*49204Scael.Fa lastlog
85*49204Scaelrecord is written ,
86*49204Scael.\" the
87*49204Scael.\" .Xr libutil 3
88*49204Scael.\" routine
89*49204Scaelthe file
90*49204Scael.Nm utmp
91*49204Scaelis opened and the
92*49204Scael.Fa utmp
93*49204Scaelrecord for the user inserted.
94*49204ScaelThis record remains there until
95*49204Scaelthe user logs out at which time it is deleted.
96*49204ScaelThe
97*49204Scael.Nm utmp
98*49204Scaelfile is used by the programs
99*49204Scael.Xr rwho 1 ,
100*49204Scael.Xr users 1 ,
101*49204Scael.Xr w 1 ,
10220770Smckusickand
103*49204Scael.Xr who 1 .
104*49204Scael.Pp
105*49204ScaelNext, the
106*49204Scael.Xr login
107*49204Scaelprogram opens the file
108*49204Scael.Nm wtmp ,
109*49204Scaeland appends the user's
110*49204Scael.Fa utmp
111*49204Scaelrecord.
112*49204ScaelThe same
113*49204Scael.Fa utmp
114*49204Scaelrecord, with an updated time stamp is later appended
115*49204Scaelto the file when the user logs out. (See
116*49204Scael.Xr init 8 . )
117*49204ScaelThe
118*49204Scael.Nm wtmp
119*49204Scaelfile is used by the programs
120*49204Scael.Xr last 1
12135603Sbosticand
122*49204Scael.Xr ac 8 .
123*49204Scael.Pp
124*49204ScaelIn the event of a date change, a shutdown or reboot, the
125*49204Scaelfollowing items are logged in the
126*49204Scael.Nm wtmp
127*49204Scaelfile.
128*49204Scael.Pp
129*49204Scael.Bl -tag -width shutdownxx -compact
130*49204Scael.It Li reboot
131*49204Scael.It Li shutdown
132*49204ScaelA system reboot or shutdown has been initiated.
133*49204ScaelThe character
134*49204Scael.Ql \&~
135*49204Scaelis placed in the field
136*49204Scael.Fa ut_line ,
137*49204Scaeland
138*49204Scael.Li reboot
139*49204Scaelor
140*49204Scael.Li shutdown
141*49204Scaelin the field
142*49204Scael.Fa ut_name .
143*49204Scael(See
144*49204Scael.Xr shutdown 8
145*49204Scaeland
146*49204Scael.Xr reboot 8 . )
147*49204Scael.Pp
148*49204Scael.It Li date
149*49204ScaelThe system time has been manually or automatically updated.
150*49204Scael(See
151*49204Scael.Xr date 1 . )
152*49204ScaelThe command name
153*49204Scael.Xr date
154*49204Scaelis recorded in the field
155*49204Scael.Fa ut_name .
156*49204ScaelIn the field
157*49204Scael.Fa ut_line ,
158*49204Scaelthe character
159*49204Scael.Ql \&{
160*49204Scaelindicates the time prior to the change, and the character
161*49204Scael.Ql \\*(Ba
162*49204Scaelindicates the new time.
163*49204Scael.El
164*49204Scael.Sh FILES
165*49204Scael.Bl -tag -width /var/log/lastlog -compact
166*49204Scael.It Pa /var/run/utmp
167*49204ScaelThe
168*49204Scael.Nm utmp file.
169*49204Scael.It Pa /var/log/wtmp
170*49204ScaelThe
171*49204Scael.Nm wtmp file.
172*49204Scael.It Pa /var/log/lastlog
173*49204ScaelThe
174*49204Scael.Nm lastlog file.
175*49204Scael.El
176*49204Scael.Sh SEE ALSO
177*49204Scael.Xr last 1 ,
178*49204Scael.Xr login 1 ,
179*49204Scael.Xr who 1 ,
180*49204Scael.Xr ac 8 ,
181*49204Scael.Xr init 8
182*49204Scael.Sh HISTORY
183*49204ScaelA
184*49204Scael.Nm utmp
185*49204Scaeland
186*49204Scael.Nm wtmp
187*49204Scaelfile format appeared in
188*49204Scael.At v6 .
189*49204ScaelThe
190*49204Scael.Nm lastlog
191*49204Scaelfile format appeared in
192*49204Scael.Bx 3.0 .
193