The last command displays the history of user login and logout actions, along with the actual time and date. It also has options that enable you to filter users who have logged in through a specific terminal. For example, last 1 will display the details of users who logged in using the first terminal. The last command retrieves information from the /var/log/wtmp file.


The syntax of the last command is:

Displaying user login/logout history.

last command examples in Linux

last Command Examples

1. To see the list of last logged in users:

2. To specify last to use mentioned file instead of /var/log/wtmp:

3. To restrict last to show specified number of lines:

# last -num 10
# last -n 10 

4. To display the state of logins for specified time:

# last -t 20140627081600 

5. To suppress the display of hostname field:

6. To display the hostname in last column:

7. To translate the IP to hostname for remote logins:

8. To print the full login and logout time and dates:

9. To display the IP in numbers and dots for remote logins:

10. To display the full user and domain name in output:

11. To display the system shutdown entries and run level changes: