TL;DR
To check login history in Linux, you can try these methods:
- Analyze the
authlog to access login-related information, including timestamps, usernames, IP addresses, and authentication methods. - Retrieve Linux login history using the
lastcommand for all users or a specific user. - Access login history by parsing the
wtmpfile, 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:
- Open the Terminal window.

- Enter the following command to view the auth log:
<strong>sudo tail -f /var/log/auth.log</strong> - The auth log displays a list of login events, including timestamps, usernames, IP addresses, and authentication methods.

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:
- Open the Terminal and type
lastto display the login history for all users.

- To retrieve the login history for a specific user, use the command
<strong>last username</strong> - The output will be:

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:
- Locate the
wtmpfile on your system. Usually, it is located in/var/log/wtmp.