In Linux/Unix, you can use the last
command to check the last time a user logged in on the system.
By default, the last
command shows the list of all users who have logged in to the system, with the most recent login listed first. To see the last time a specific user logged in, you can run the following command:
last <username>
Replace <username>
with the username of the user you want to check. For example:
last john
The output of the last
command will show the date and time of the user’s last login, as well as the IP address from which the user logged in and the type of terminal used (e.g., pts/0
). If the user has never logged in, the output will show Username not found
.
Note that the last
command only shows the information stored in the wtmp
file, which is a log of all logins and logouts on the system. The wtmp
file is maintained by the utmpd
service, and its size and contents can vary depending on the specific Linux/Unix distribution and configuration.