Delete Login History on Linux Server


On the Linux systems there are three standard commands that show the information about last logged in userslastlastb, and lastlog.

The output of these commands include: login-name, last login time, IP address, port etc.

And sometimes, to keep anonymity, it is required to erase last login history.

Check Login History

To check the last login history, including the history of login attempts that failed, run one of the commands from the table below.

Command Logfile Description
last /var/log/wtmp Lists successful login/logout history
lastb /var/log/btmp Shows the bad login attempts
lastlog /var/log/lastlog Shows the most recent login

You already know how to check the last login history in Linux, so now it is time to learn how to clear it.

Delete Login History

As you can see from the table, the information about the last logged in users, including failed attempts to login, is stored in the specific binary files that you can’t edit but can easily empty them.

To remove all the information about the last logged in users, you have to clear the files where this information is kept:

echo > /var/log/wtmp
echo > /var/log/btmp
echo > /var/log/lastlog

Now, you have deleted all information about most recently logged users.

  • clear logs, privacy
  • 65 Users Found This Useful
Was this answer helpful?

Related Articles

View Server PHP Environment with phpinfo.php

The phpinfo() function outputs a huge amount of information about the system you're using, such...

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH....

How to Create Sudo User on CentOS

This article provides step-by-step setup guide for adding Sudo user to CentOS system. The sudo...

How to Use Sudo

This article provides a guide to using a Sudo user on CentOS server. From the command line,...

Set Server Time Zones with Timedatectl

This article provides a guide to setting the server time and server time zone settings using...