Linux / Unix last Command Examples

Linux / Unix last Command Examples

The last command is used to display information about the users who have recently logged in or out of a Linux or Unix system. It reads the wtmp file, which is a record of all logins and logouts on the system.

Here are some examples of how you can use the last command:

  • To display a list of the most recent logins and logouts, you can use the last command with no options:
last
So‮www:ecru‬.lautturi.com

This will display a list of the logins and logouts, along with the date and time of the login or logout, the user's name, and the terminal or hostname from which the user logged in.

  • To display a list of logins and logouts for a specific user, you can use the -u option followed by the user's name:
last -u username

This will display a list of logins and logouts for the specified user.

  • To display a list of logins and logouts from a specific terminal or hostname, you can use the -t option followed by the terminal or hostname:
last -t terminal_name

This will display a list of logins and logouts from the specified terminal or hostname.

  • To display a list of logins and logouts that occurred within a specific time range, you can use the -s and -e options, followed by the start and end dates:
last -s start_date -e end_date

This will display a list of logins and logouts that occurred within the specified time range. The start and end dates should be in the format YYYY-MM-DD.

For more information about the last command and its available options, you can consult the last man page or use the last --help command.

Created Time:2017-10-29 22:08:58  Author:lautturi