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