Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My terminal history has hundreds of command, but I just want to keep a few of them

Is there a way to manually edit the list of command executed in the terminal?

share|improve this question
up vote 5 down vote accepted

While this would be rather tedious now that almost every command gets logged in your history, you can edit your ~/.bash_history file.

share|improve this answer

to review your history, open the terminal and just type history

I would recommend making a copy first by opening a terminal and using this CLI cp ~/.bash_history ~/.bash_history_old

then edit the "old" one, Once you are satisfied with the result run this cp ~/.bash_history_old ~/.bash_history this will replace the current history. You will be prompted to overwrite y/n?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.