UTMP(5)
NAME
utmp − log-in records
USAGE
#include <utmp.h>
DESCRIPTION
The utmp file records information about who is currently using the node. The file is a sequence of entries with the following structure declared in the include file: #include <sys/types.h> #define UTMP_FILE “/etc/utmp” struct utmp { char ut_user[32]; /* user login name */ char ut_id[4]; /* /etc/lines id (usually line #)*/ char ut_line[12]; /* tty name */ short ut_pid; /* process id */ short ut_type; /* type of entry */ struct exit_status { short e_termination; /* process termination status */ short e_exit; /* process exit status */ } ut_exit; /* the exit status of a process /* marked as DEAD_PROCESS */ time_t ut_time; /* time entry was made */
char ut_host[32]; /* host name, if remote */ };
#define ut_name ut_user
/* definitions for ut_type */
#define EMPTY0 #define RUN_LVL1 #define BOOT_TIME 2 #define OLD_TIME 3 #define NEW_TIME 4 #define INIT_PROCESS 5 /*currently unused*/ /* (process spawned by “init”)*/ #define LOGIN_PROCESS 6 /* currently unused */ /* (“getty” process waiting for login) */ #define USER_PROCESS 7 /* user process */ #define DEAD_PROCESS 8 #define ACCOUNTING 9 #define UTMAXTYPE ACCOUNTING /* largest ut_type value */
/* special strings or formats used in the ut_line field when */ /* accounting for something other than a process */ /* no string for the ut_line field can be more than 11 chars + */ /* a NULL in length */
#defineRUNLVL_MSG“run−level %c” #defineBOOT_MSG “system boot” #define OTIME_MSG “old time” #define NTIME_MSG “new time”
This structure gives the name of the special file associated with the user’s terminal, the user’s log-in name, and the time of the log-in in the form of time (3).
FILES
/etc/utmp record of who is currently using the node (link to ‘node_data/etc.utmp)