TrumanWong

last

List information about current and past users who have logged into the system

Supplementary instructions

last command is used to display the user's latest login information. Execute the last command alone, it will read the file /var/log/wtmp and display the list of all users logged into the system recorded in the file.

grammar

last(option)(parameter)

Options

-a: Display the host name or IP address from where you log in to the system on the last line;
-d: Convert IP address to host name;
-f <record file>: Specify the record file.
-n <Number of display columns> or -<Number of display columns>: Set the number of display columns for the list;
-R: Do not display the host name or IP address logged into the system;
-x: Display system shutdown, restart, and execution level changes and other information.

Parameters

  • Username: Display user login list;
  • Terminal: Displays the login list from the specified terminal.

Example

The last command is used to display user login status. The following is a record that directly displays a fixed number of lines:

last -10
root pts/0 221.6.45.34 Tue Dec 17 09:40 still logged in
root pts/0 221.6.45.34 Mon Dec 16 09:00 - 11:57 (02:56)
root pts/0 222.94.97.122 Sun Dec 15 20:39 - 23:28 (02:48)
root pts/0 222.95.209.80 Sat Dec 14 14:39 - 14:58 (00:18)
root pts/0 221.6.45.34 Thu Dec 12 16:55 - 17:37 (00:41)
root pts/0 49.65.139.195 Wed Dec 11 20:40 - 21:16 (00:35)
root pts/0 49.65.139.195 Wed Dec 11 19:46 - 20:03 (00:17)
root pts/0 221.6.45.34 Tue Dec 10 14:41 - 15:52 (01:10)
root pts/0 221.6.45.34 Mon Dec 9 17:24 - 17:30 (00:06)
root pts/0 221.6.45.34 Mon Dec 9 09:38 - 11:41 (02:02)