Sometimes it is necessary for different aspects to delete the history of the bash history or to remove parts of it. For example, this can be very useful if you have inadvertently typed sensitive data such as passwords into the bash.
Surely you could edit the ".bash_historie", but it is also more efficient without leaving a trace.
The entire content of the history can be removed with the following command:
$ history -cw
Attribute | Function |
-c |
This attribute deletes the history list |
-w |
This attribute writes the current history into the history |
The attribute reads the current history file and appends its content to the history list
$ history -d 420
Attribute | Function |
-d |
The attribute, together with the line number, triggers the relevant line from the bash history |
If only the current session disappears from the history, then with this command happens.
$ history -r
Attribute | Function |
-r |
The attribute reads the current history file and appends its content to the history list |
It is also possible to avoid storing a command in the history by inserting a space before the command.
$ <space> command
Unless HISTFILE is disabled, all commands in the current bash session until logout are not written to the logged-in user's .bash _history. To do this, the following command must be issued at the beginning of the bash session:
$ unset HISTFILE