LinuxCommandLibrary

sessreg

Manage user login and logout records

SYNOPSIS

sessreg [-a] [-d] [-w wtmp_file] [-u utmp_file] [-l line_name] [-h hostname] username

PARAMETERS

-a
    Instructs sessreg to add a new session entry. This is the default action if neither -a nor -d is specified.

-d
    Instructs sessreg to delete an existing session entry. Used when a user logs out, marking the end of a session.

-w wtmp_file
    Specifies an alternative path for the wtmp file, which logs historical login/logout events. The default is typically /var/log/wtmp.

-u utmp_file
    Specifies an alternative path for the utmp file, which records current logged-in users. The default is typically /var/run/utmp.

-l line_name
    Defines the line name associated with the session. For X sessions, this is often the display name (e.g., :0). For terminal sessions, it might be the TTY device name.

-h hostname
    Specifies the hostname from which the session originates. The default is usually the local host's hostname.

DESCRIPTION

sessreg is a utility designed to record user session activity in the system's accounting files, specifically utmp and wtmp.

These files maintain records of who is currently logged in (utmp) and a historical log of logins and logouts (wtmp). It's commonly used in graphical environments, particularly by display managers like XDM, to mark the beginning or end of an X session.

By registering sessions, sessreg ensures that system commands such as who, w, users, and last can accurately report active users and past login events. It can add an entry for a new session or delete an entry when a session terminates, thereby providing a comprehensive record of user presence on the system. This contributes to system monitoring, security auditing, and resource management.

CAVEATS

sessreg primarily registers sessions for local logins, often within the context of graphical display managers. It may not be directly used for SSH or other remote login types, which are typically handled by sshd or login itself.

Incorrect usage or insufficient file permissions could lead to inaccurate login records. It requires appropriate permissions to write to the utmp and wtmp files.

FILE MANAGEMENT

sessreg interacts directly with two crucial system accounting files:
/var/run/utmp: Records currently logged-in users.
/var/log/wtmp: Maintains a historical log of all login and logout events.

These files are fundamental for various system tools to provide accurate information about user activity.

INTEGRATION WITH DISPLAY MANAGERS

The most common use case for sessreg is its invocation by graphical display managers (e.g., xdm, gdm, lightdm). These managers run sessreg at the start of a user's X session (with -a) and again at the end (with -d) to ensure that graphical logins are properly tracked alongside traditional console or remote logins.

HISTORY

sessreg is a long-standing utility within the X Window System, primarily associated with display managers like xdm. Its core function, to accurately update utmp and wtmp files for graphical sessions, has remained consistent since its inception. It has been a standard component in X environments for decades, ensuring proper session accounting and system monitoring capabilities.

SEE ALSO

utmp(5), wtmp(5), who(1), w(1), last(1), login(1), xdm(1)

Copied to clipboard