How to Clear BASH Command Line History in Linux

By | May 10, 2018

The bash history keeps a record of all commands executed by a user on the Linux command line. This allows you to easily run previously executed commands by using the “up arrow” or “down arrow” keys to scroll through the command history file.

In this article, we will show you two simple ways to clear your command-line history on a Linux system.

The major reason for removing command-line history from the Linux terminal is to prevent another user, who could be using the same account.

For instance if you have typed a command that contained a password in plain-text and you don’t want another system user or an attacker to see this password, you need to delete or clear the history file.

If you look into th bash history file towards the end, you will see the password typed above in there.

history

The bash_history file is normally located in a user’s home directory /home/username/.bash_history.

To remove a single line from the history file, use the -d option. For example, if you want to clear a command where you entered clear-text password as in the scenario above, find the line number in the history file and run this command.

To delete or clear all the entries from bash history, use the history command below with the -c option

Alternatively, you can use the command below to delete history of all last executed commands permanently in the file.

www.pdf24.org    Send article as PDF   
Category: VPS

2 thoughts on “How to Clear BASH Command Line History in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *