last - See any user login history

Written by
Date: 2009-04-25 10:36:30 00:00


last is another command for the system admin tool box, it displays the login history of all or any specific user.

Yo do not need to be root to use it, let's see some ways to use it.

last

The output would be:

ggarron  pts/1        200.87.61.2      Sat Apr 25 11:02   still logged in   
ggarron  pts/0        200.87.61.2      Sat Apr 25 10:41   still logged in   
publico  pts/0        10.1.1.86        Fri Apr 24 16:25 - 16:47  (00:22)    
ggarron  pts/0        200.87.61.2      Sat Apr 18 19:34 - 19:54  (00:20)    
ggarron  pts/0        10.1.1.43        Wed Apr 15 15:27 - 10:30  (19:03)    
root     pts/0        200.87.61.2      Mon Apr 13 22:41 - 01:11  (02:29)    
ggarron  pts/0        200.87.61.2      Sat Apr 11 15:25 - 15:28  (00:02)    
ggarron  pts/0        200.87.61.2      Fri Apr 10 10:40 - 22:33  (11:53)    
publico  pts/0        10.1.1.86        Thu Apr  9 12:02 - 12:02  (00:00)    
publico  pts/0        10.1.1.86        Thu Apr  9 12:01 - 12:01  (00:00)

You can also make the IP or name of the system from where the users logged it, to appear in the last column

last -a

And the output would be:

ggarron  pts/1        Sat Apr 25 11:02   still logged in    200.87.61.2
ggarron  pts/0        Sat Apr 25 10:41   still logged in    200.87.61.2
publico  pts/0        Fri Apr 24 16:25 - 16:47  (00:22)     10.1.1.86
ggarron  pts/0        Sat Apr 18 19:34 - 19:54  (00:20)     200.87.61.2
ggarron  pts/0        Wed Apr 15 15:27 - 10:30  (19:03)     10.1.1.43
root     pts/0        Mon Apr 13 22:41 - 01:11  (02:29)     200.87.61.2
ggarron  pts/0        Sat Apr 11 15:25 - 15:28  (00:02)     200.87.61.2
ggarron  pts/0        Fri Apr 10 10:40 - 22:33  (11:53)     200.87.61.2
publico  pts/0        Thu Apr  9 12:02 - 12:02  (00:00)     10.1.1.86
publico  pts/0        Thu Apr  9 12:01 - 12:01  (00:00)     10.1.1.86

Or only displa the history for a given user.

last publico -a

The output this time will be something like this:

publico  pts/0        Fri Apr 24 16:25 - 16:47  (00:22)     10.1.1.86
publico  pts/0        Thu Apr  9 12:02 - 12:02  (00:00)     10.1.1.86
publico  pts/0        Thu Apr  9 12:01 - 12:01  (00:00)     10.1.1.86