linux-logins

Parses the /var/log/wtmp file to query the terminal login and logout history on a Linux system. Returns the user, source IP, terminal, and login/logout times for each login session as structured fields.

Command properties

PropertyValue
Command typeDriver query
Required permissionAdministrator
License usageCounted
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

linux-logins

Output fields

FieldTypeDescription
_timetimestampLogin time. Same value as the login_time field.
src_ipipaddrSource IP address. Returns null for local logins.
hoststringSource hostname (IP address or domain). Returns null if the value is empty.
pidintegerLogin process ID
userstringLogged-in username
ttystringTerminal device name (e.g., pts/0, tty1)
login_timetimestampLogin time
logout_timetimestampLogout time. Returns null if still logged in or if no logout record exists.

Error codes

Parsing errors
Error codeMessageDescription
95040no-read-permissionExecuted without administrator privileges
Runtime errors
Error codeMessageDescriptionAction on error
--The /var/log/wtmp file could not be readAborts query execution

Description

The linux-logins command parses the /var/log/wtmp file in binary format to extract the terminal login history. It recognizes UserProcess type records in the wtmp file as logins, and assigns the time of the next DeadProcess record on the same terminal as the logout time. If a new login occurs on the same terminal before the previous session logs out, the logout_time of the previous session is set to null.

The _time field is assigned the same value as login_time to enable time-based queries.

Examples

  1. Query all login history

    linux-logins
    

    Queries all terminal login history on the system.

  2. Filter only remote access history

    linux-logins
    | search isnotnull(src_ip)
    

    Filters only login history from remote connections.

  3. Query login history for a specific user

    linux-logins
    | search user == "root"
    

    Queries only the login history of the root user.

  4. Query currently active sessions

    linux-logins
    | search isnull(logout_time)
    

    Queries sessions with no logout time, i.e., sessions that are currently active.