UTMP(5) BSD Programmer's Manual UTMP(5) NNAAMMEE uuttmmpp, wwttmmpp, llaassttlloogg - login records SSYYNNOOPPSSIISS ##iinncclluuddee <<uuttmmpp..hh>> DDEESSCCRRIIPPTTIIOONN The file <_u_t_m_p_._h> declares the structures used to record information about current users in the file uuttmmpp, logins and logouts in the file wwttmmpp, and last logins in the file llaassttlloogg. The time stamps of date changes, shutdowns and reboots are also logged in the wwttmmpp 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 _/_e_t_c_/_d_a_i_l_y or the script _/_e_t_c_/_w_e_e_k_l_y. (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 llaassttlloogg.. 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 _q_u_i_e_t, see login(1).) The login pro- gram then records the new login time in the file llaassttlloogg. After the new _l_a_s_t_l_o_g record is written , the file uuttmmpp is opened and the _u_t_m_p record for the user inserted. This record remains there until the user logs out at which time it is deleted. The uuttmmpp file is used by the programs rwho(1), users(1), w(1), and who(1). Next, the login program opens the file wwttmmpp, and appends the user's _u_t_m_p record. The same _u_t_m_p record, with an updated time stamp is later ap- pended to the file when the user logs out. (See init(8).) The wwttmmpp 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 wwttmmpp file. reboot shutdown A system reboot or shutdown has been initiated. The charac- ter `~' is placed in the field _u_t___l_i_n_e, and reboot or shutdown in the field _u_t___n_a_m_e. (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 _u_t___n_a_m_e. In the field _u_t___l_i_n_e, the character `{' indi- cates the time prior to the change, and the character `|' in- dicates the new time. FFIILLEESS /var/run/utmp The uuttmmpp ffiillee.. /var/log/wtmp The wwttmmpp ffiillee.. /var/log/lastlog The llaassttlloogg ffiillee.. SSEEEE AALLSSOO last(1), login(1), who(1), ac(8), init(8) HHIISSTTOORRYY A uuttmmpp and wwttmmpp file format appeared in Version 6 AT&T UNIX. The llaassttlloogg file format appeared in 3.0BSD. 4th Berkeley Distribution June 5, 1993 2