lastlog

Linux · Users and permissions · reference only

What it does

Shows the most recent login of every account on the system, with the port and origin.

Syntax

lastlog [opciones]

Options and parameters

  • -u usuario

    Shows only that user's data (UID ranges are also accepted).

  • -t días

    Shows only logins from the last N days.

  • -b días

    Shows only logins older than N days ago.

  • -C

    Clears the login record of the user given with -u (requires root).

  • -S

    Sets the login record of the user given with -u to the current time (requires root).

Usage examples

  • lastlog

    Lists the last login of every account.

  • lastlog -u ana

    Shows only ana's last login.

  • lastlog -t 7

    Shows the accounts that logged in during the last week.

  • lastlog -b 90

    Finds accounts with no activity in the last 90 days.

Notes and common mistakes

  • It reads the /var/log/lastlog file.
  • Accounts that have never logged in are marked as such.

Related commands