Linux command (28) last command

last command

  • Function Description: display the list of recently logged in users

    The last command will read the wtmp file under / var/log / and display the user name of the login system recorded in the file.

  • Usage: last

    option effect
    -n Set the number of lines to display the list
    -R Do not display the host name and IP address of the login

    Example: display information about the most recently logged in user

    root     pts/1        192.168.3.98     Mon May 25 18:57   still logged in   
    root     pts/0        192.168.3.98     Mon May 25 17:21 - 21:01  (03:40)    
    root     pts/0        192.168.3.98     Mon May 25 15:44 - 17:21  (01:36)    
    root     tty1                          Mon May 25 15:44   still logged in   
    reboot   system boot  3.10.0-957.el7.x Mon May 25 23:44 - 22:50  (00:-53)   
    root     pts/1        192.168.3.98     Tue Jan 22 23:33 - crash (24961+00:11
    root     pts/0        192.168.3.98     Tue Jan 22 22:57 - crash (24961+00:46
    root     pts/2        192.168.3.98     Tue Jan 22 17:34 - 19:55  (02:20)    
    root     pts/0        192.168.3.98     Wed Feb 21 00:13 - 19:43 (-24136+-4:-
    root     tty6                          Wed Feb 21 00:12 - 23:33 (-24136+00:-
    root     pts/1        192.168.3.98     Mon May 11 11:17 - 19:13 (-24946+-16:
    root     pts/0        192.168.3.98     Sun May 10 10:06 - 12:33 (1+02:26)   
    root     tty5                          Sun May 10 09:52 - 23:33 (-24945+-10:
    root     tty4                          Sun May 10 09:52 - 23:33 (-24945+-10:
    root     tty3                          Sun May 10 09:52 - 23:33 (-24945+-10:
    root     tty2                          Sun May 10 09:52 - 23:33 (-24945+-10:
    root     tty6                          Sun May 10 09:51 - 11:16 (1+01:25)   
    root     pts/0        192.168.3.98     Sun May 10 08:42 - 10:06  (01:24)    
    root     tty1                          Sun May 10 08:41 - 23:33 (-24945+-9:-
    reboot   system boot  3.10.0-957.el7.x Sun May 10 08:36 - 22:50 (15+14:13)  
    

    Example 2: display the 5 most recently logged in users

    [root@node1 ~]# last -n 5
    root     pts/1        192.168.3.98     Mon May 25 18:57   still logged in   
    root     pts/0        192.168.3.98     Mon May 25 17:21 - 21:01  (03:40)    
    root     pts/0        192.168.3.98     Mon May 25 15:44 - 17:21  (01:36)    
    root     tty1                          Mon May 25 15:44   still logged in   
    reboot   system boot  3.10.0-957.el7.x Mon May 25 23:44 - 22:52  (00:-51)   
    
    

Keywords: Linux

Added by scott56hannah on Tue, 26 May 2020 18:25:56 +0300