BSD 4_4 development
[unix-history] / usr / share / man / cat5 / utmp.0
UTMP(5) BSD Programmer's Manual UTMP(5)
N\bNA\bAM\bME\bE
u\but\btm\bmp\bp, w\bwt\btm\bmp\bp, l\bla\bas\bst\btl\blo\bog\bg - login records
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
#\b#i\bin\bnc\bcl\blu\bud\bde\be <\b<u\but\btm\bmp\bp.\b.h\bh>\b>
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
The file <_\bu_\bt_\bm_\bp_\b._\bh> declares the structures used to record information
about current users in the file u\but\btm\bmp\bp, logins and logouts in the file
w\bwt\btm\bmp\bp, and last logins in the file l\bla\bas\bst\btl\blo\bog\bg. The time stamps of date
changes, shutdowns and reboots are also logged in the w\bwt\btm\bmp\bp file.
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 ei-
ther the script _\b/_\be_\bt_\bc_\b/_\bd_\ba_\bi_\bl_\by or the script _\b/_\be_\bt_\bc_\b/_\bw_\be_\be_\bk_\bl_\by. (See cron(8).)
#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;
};
Each time a user logs in, the login program looks up the user's UID in
the file l\bla\bas\bst\btl\blo\bog\bg.\b. 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 _\bq_\bu_\bi_\be_\bt, see login(1).) The login pro-
gram then records the new login time in the file l\bla\bas\bst\btl\blo\bog\bg.
After the new _\bl_\ba_\bs_\bt_\bl_\bo_\bg record is written , the file u\but\btm\bmp\bp is opened and the
_\bu_\bt_\bm_\bp record for the user inserted. This record remains there until the
user logs out at which time it is deleted. The u\but\btm\bmp\bp file is used by the
programs rwho(1), users(1), w(1), and who(1).
Next, the login program opens the file w\bwt\btm\bmp\bp, and appends the user's _\bu_\bt_\bm_\bp
record. The same _\bu_\bt_\bm_\bp record, with an updated time stamp is later ap-
pended to the file when the user logs out. (See init(8).) The w\bwt\btm\bmp\bp file
is used by the programs last(1) and ac(8).
In the event of a date change, a shutdown or reboot, the following items
are logged in the w\bwt\btm\bmp\bp file.
reboot
shutdown A system reboot or shutdown has been initiated. The charac-
ter `~' is placed in the field _\bu_\bt_\b__\bl_\bi_\bn_\be, and reboot or
shutdown in the field _\bu_\bt_\b__\bn_\ba_\bm_\be. (See shutdown(8) and
reboot(8).)
date The system time has been manually or automatically updated.
(See date(1).) The command name date is recorded in the
field _\bu_\bt_\b__\bn_\ba_\bm_\be. In the field _\bu_\bt_\b__\bl_\bi_\bn_\be, the character `{' indi-
cates the time prior to the change, and the character `|' in-
dicates the new time.
F\bFI\bIL\bLE\bES\bS
/var/run/utmp The u\but\btm\bmp\bp f\bfi\bil\ble\be.\b.
/var/log/wtmp The w\bwt\btm\bmp\bp f\bfi\bil\ble\be.\b.
/var/log/lastlog The l\bla\bas\bst\btl\blo\bog\bg f\bfi\bil\ble\be.\b.
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
last(1), login(1), who(1), ac(8), init(8)
H\bHI\bIS\bST\bTO\bOR\bRY\bY
A u\but\btm\bmp\bp and w\bwt\btm\bmp\bp file format appeared in Version 6 AT&T UNIX. The l\bla\bas\bst\btl\blo\bog\bg
file format appeared in 3.0BSD.
4th Berkeley Distribution June 5, 1993 2