Closed Captioning Closed captioning available on our YouTube channel

How to use the last command: 2-Minute Linux Tip

Network World | May 20, 2019

In this episode of 2-Minute Linux Tips, Sandra demonstrates the last command. It that shows recent logins – such as the last time you logged in but with the logins in reverse order.

Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the last command that shows recent logins – such as the last time you logged in but with the logins in reverse order (most recent logins first).
Typed without any arguments, last will show all logins recorded in the current /var/log/wtmp file. This is the file that saves login information – including usernames, dates and times, the terminal used and incoming IP addresses.
If you’re only interested in some particular user’s logins, you can supply that individual’s username. For example:
We can see that nemo logs in infrequently and from different IP addresses – though it might be that the system in question has a dynamically assigned IP address and these logins are from the same system. We can also see how long nemo spent on the system (3 or 4 hours in some of the logins shown).
Depending on how often a system is logged into, a wtmp file might cover a long period of time. Generally, wtmp files are rotated based on file size or timing – for example, whether they reach 1 megabyte in size or a month has passed. The /etc/logrotate.d/wtmp file on the system will probably provide a description of the rotation schedule. For example, these settings cause the file to be rotated once a month if the file has reached 1 megabyte in size.
Note that the older files will have names like wtmp.1 and wtmp.2.
That’s your Linux tip for today.
If you have questions or would like to suggest a topic, please add a comment below.
And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and
Featured videos from