Read more

How to remove entries from the bash history

Deleted user #4117
December 02, 2020Software engineer

Sometimes you accidentally generate entries in the bash history that you do not want to have there (e.g. commands with credentials).
Here's how to remove single entries.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

You can look at the bash history with the history command.
To see e.g. the last 5 entries, use history | tail -n 5:

>history | tail -n 5
 1994  my-secret-command
 1995  cd xyz-mnt/
 1996  ls
 1997  cd appliance/
 1998  cd ..

Each entry has a number. You can use that to delete it: history -d 1994. Note that as you delete entries, the numbers of the following entries will change.

Posted to makandra dev (2020-12-02 10:43)