I have a couple questions about the terminal or command line history that is stored in ~/.bash_history
.
-
I can see the file in the terminal with the
history
command but if I try to open it withgedit bash_history
the file is completely empty. Why? -
I've found how to delete a certain number of lines in the file from the terminal with this code line:
for i in {1..N}; do history -d N; done
where N is the number of lines (or commands) you want to delete, but now the history file shows this last command and thats not very smart if you're trying to cover your stuff. So the question is:
How can I give the last code line and make sure this doesn't get recorded?
Best Answer
You just forgot the preceding dot, the command to open your (bash) terminal history file is
This file is only updated when you close a terminal.
To remove the last 10 lines from this file and don't get this command itself recorded, open a new terminal and execute the following chain of commands:
or
or
sed
orhead
respectively deletes the selected lines from~/.bash_history
,history -c
clears the terminal's history andexit
closes it.