Removing Entries from the Linux Command Line History File

First you can avoid have commands saved to the history file by preceding them with a leading space. Here’s an example:

$  nano  /path/to/my/file/passwords.txt
  ^-- additional space character

If there are pre-existing commands that you want removed, just open the history file in nano and delete the entries you want removed. Here’s how you do it:

$ nano ~/.bash_history

Be aware that entries are only committed to the history file when a user exits a log-in session. Hence, to remove entries committed during your current session, log-out and then log-in as the same user.