Delete an entry from the Linux history

To delete an entry from the history, e.g. because it contains a username or password, show all history entries by typing


in the command line and then delete the entry with the -d parameter by specifying the history number, for example

history -d 498

to delete line 498. Then save the change with

history -w

If you do not save the change, the command would still be visible if you run the history command in a new shell. In newer versions of the Bash shell you can just put a space in front of the command and the command will not be stored in the history.

Leave a Reply

Your email address will not be published.