Forrest logo
tool overview
On this page you find all important commands for the CLI tool last. If the command you are looking for is missing please ask our AI.

last

The "last" command line tool is used for retrieving information about previous user logins and system shutdowns. It displays a list of recently logged in users, along with the corresponding login time and duration of their session. The output also includes information about system startups, shutdowns, and runlevel changes. It reads the data from the /var/log/wtmp file, which stores login records. One of the main applications of the "last" command is to investigate system activity and user login patterns. You can use additional command-line options like '-n' to specify the number of records to display. The "-f" flag can be used to specify an alternative file to read login records from. You can also filter the output based on a specific username or terminal using the "-s" and "-t" options respectively. The "last" command allows system administrators to track user logins, identify active sessions, and monitor system uptime. It is commonly used for security auditing, troubleshooting login issues, and managing user access to the system.

List of commands for last:

  • last:tldr:13789 last: Specify how many of the last logins to show.
    $ last -n ${login_count}
    try on your machine
    explain this command
  • last:tldr:30795 last: View all recorded shutdowns (i.e., the last logins of the pseudo user "shutdown").
    $ last shutdown
    try on your machine
    explain this command
  • last:tldr:98bd1 last: View last logins, their duration and other information as read from `/var/log/wtmp`.
    $ last
    try on your machine
    explain this command
  • last:tldr:9c50f last: Print the full date and time for entries and then display the hostname column last to prevent truncation.
    $ last -F -a
    try on your machine
    explain this command
  • last:tldr:d2b99 last: View all logins by a specific user and show the IP address instead of the hostname.
    $ last ${username} -i
    try on your machine
    explain this command
  • last:tldr:e33c5 last: View all recorded reboots (i.e., the last logins of the pseudo user "reboot").
    $ last reboot
    try on your machine
    explain this command
tool overview