The “last” command in Linux/Unix is used to display a list of recent login sessions on the system. Here are some examples of using the last command:
- Display a list of all login sessions:
$ last
- Display a list of only the latest login session for each user:
$ last -f /var/log/wtmp -1
- Display a list of all login sessions from a specific date:
$ last -f /var/log/wtmp --since YYYY-MM-DD
- Display a list of all login sessions for a specific user:
$ last -f /var/log/wtmp username
- Display a list of all login sessions from a specific IP address:
$ last -f /var/log/wtmp -i IP_ADDRESS
- Display the list of all login sessions in reverse order (most recent first):
$ last -f /var/log/wtmp -r
These are just a few examples of the last command. You can refer to the man page for more options and usage examples.