Published: July 22, 2026
Read: 8 min
In: Technology & Development

Written by

Reviewed by

Last updated: June 25, 2023

Expert verified

SVG Image

TL;DR

To check login history in Linux, you can try these methods:

  1. Analyze the auth log to access login-related information, including timestamps, usernames, IP addresses, and authentication methods.
  2. Retrieve Linux login history using the last command for all users or a specific user.
  3. Access login history by parsing the wtmp file, which stores login records in Linux systems.

Checking log history is crucial for maintaining security, troubleshooting system issues, and ensuring compliance. By implementing best practices such as regular monitoring, setting up alerts, and retaining logs, administrators can detect unauthorized access attempts, identify root causes of problems, and meet regulatory requirements. The benefits include enhanced security monitoring, efficient troubleshooting, and compliance with industry standards.

Read the guide below to learn different methods to check login history in Linux. Also, explore best practices and benefits of checking Linux login history.

Keeping track of login history in Linux systems is essential for maintaining the security and integrity of your environment. By monitoring login activities, you can detect unauthorized access attempts, identify potential security breaches, and ensure compliance with regulatory standards. In this article, I will provide you with a detailed overview of different methods to check login history in Linux, enabling you to protect your system proactively. I will also discuss some best practices to check login history in Linux and the benefits of keeping track of login details.

How to Check Login History in Linux

To check login history in Linux, you can examine the auth log for comprehensive login event details, utilize the last command to retrieve login records for all users or specific users and parse the wtmp file to delve into historical login information.

1. Examining the Auth Log

The auth log is a valuable source of login-related information in Linux systems. By examining the auth log, you can access a comprehensive list of login events, including timestamps, usernames, IP addresses, and authentication methods. To access and analyze the auth log, follow these steps:

  1. Open the Terminal window. 
opening terminal 9
  1. Enter the following command to view the auth log: 

<strong>sudo tail -f /var/log/auth.log</strong>
  1. The auth log displays a list of login events, including timestamps, usernames, IP addresses, and authentication methods.
viewing auth.log history of the user

2. Utilizing the Last Command

The last command offers a straightforward way to retrieve Linux login history. Using the last command, you can view the login records for all users or retrieve the login history for a specific user. Follow these steps to use the last command:

  1. Open the Terminal and type last to display the login history for all users.
retrieving login history of all the users
  1. To retrieve the login history for a specific user, use the command 

<strong>last username</strong>
  1. The output will be:
viewing login history of a specific user

3. Parsing the Wtmp File

The wtmp file stores login records in Linux systems and can be parsed to access login history. Parsing the wtmp file lets you delve into historical login records and gain insights into user logins, session durations, and other relevant details. Here’s how you can parse the wtmp file to access login history:

  1. Locate the wtmp file on your system. Usually, it is located in /var/log/wtmp.