Checking last logins with lastlog
lastlog is a program available on most Linux distributions. It formats and prints the contents of the last login log file, /var/log/lastlog (which is a usually a very sparse file), including the login name, port, and last login date and time. It is similar in functionality to the BSD program last, also included in Linux distributions; however, last parses a different binary database file (/var/log/wtmp and /var/log/btmp).
The lastlog command in Linux/Unix systems is used to display the recent login history of users. It reads data from the /var/log/lastlog file and presents it in a human-readable format.
The output of the lastlog command typically includes the following information for each user:
Username: the name of the user who logged in.
Port: the terminal or connection port used for the login.
From: the IP address or hostname of the remote system used for the login.
Latest Login: the date and time of the user's most recent login.
Here's an example of how to use the lastlog
command:
lastlog
This will display the last login information for all users on the system.
You can also specify a particular user to display only their login history:
lastlog -u username
Replace "username" with the actual username of the user you want to check.