Centos – “Last” command: How to show latest user login

centoslast

As I know, the last command shows recent logins by all users. But my PC (CentOS) has been used for roughly a year, and there are many users logged. I tried to used the last command, but it just showed from June 2013 to September 2013.

My question is: how can I show the latest users that have logged in recently, say (December 2013 through Jan 2014)?

Best Answer

last reads from a log file, usually /var/log/wtmp and prints the entries of successful login attempts made by the users in the past. The output is such that the last logged in users entry appears on top. In your case perhaps it went out of notice because of this.

In order to check when was the file /var/log/wtmp was written last, you can use stat command:

stat /var/log/wtmp

In order to print the output in reverse, you can pipe output of last to GNU tac (opposite of cat) as follows:

last | tac
Related Question