Ubuntu – How to prevent commands being removed from history

bashcommand linehistory

I have noticed that when I go up through my commands using the arrow keys, UP and DOWN, that if I then edit a command, it edits it in history, and I can even remove a command like that, however I do not want it to have this affect on the commands in history, I don't want it to actually delete them in the history, only allow me to edit what I am typing, but not actually modify the history through this. So how can I make it so that this does not actually modify the history, but just the command that I execute?

Best Answer

I asked something quite similar in Unix & Linux: How to undo changes in the commands-history?.

The great answer I got from Gilles says:

As long as you've edited a history entry but not pressed Enter yet, to go back to the original entry, repeatedly press Ctrl+_ — the undo command — until it doesn't make any further change. You're back to the original entry.