There are some interesting articles on how to clear out the last login history, however, all of them offer the same result. From several approaches, I have formulated a short and efficient one-liner.
The three files are /var/log/wtmp (successful login/logout) /var/log/btmp (bad login attempts) and /var/log/lastlog (last logged in). The are respectively accessible via the last, lastb, and lastlog commands.
This approach is offered by many sites.
echo > /var/log/wtmp echo > /var/log/btmp echo > /var/log/lastlog
From that I tried the following and this didn't work and produced an error /var/log/[bw]tmp: ambiguous redirect
> /var/log/[bw]tmp /var/log/lastlog
However, after trying a few things, I discovered the truncate command. By using the -s switch and selecting the size of zero, we can achieve a working one-liner.
truncate /var/log/[wb]tmp /var/log/lastlog -s0