Page 1 of 1

Clearing the history in terminal ? [SOLVED]

Posted: Mon Mar 13, 2023 4:24 pm
by Jasper

Hi there

I wanted to clear the history of entries that I have used in terminal (Fossapup64-95)

history -c

however when I run the same command

history

it shows that it is still populated with entries.

The Help file does state the

-c

is the correct input variable to enter to clear entries/history

Any ideas/suggestions?


Re: Clearing the history in terminal ?

Posted: Mon Mar 13, 2023 5:35 pm
by Burunduk
Jasper wrote: Mon Mar 13, 2023 4:24 pm

-c

is the correct input variable to enter to clear entries/history

It clears the history for the current session. You also need to write it back to the history file (empty it): history -c && history -w
You can make an alias for it: alias nohist='history -c && history -w'
I prefer to delete the current session history only if it's full of garbage, so I have an alias nohist='history -c && history -r' in my .bashrc

By the way, if you don't need a bash history at all, add unset HISTFILE to the /root/.bashrc file.


Re: Clearing the history in terminal ?

Posted: Tue Mar 14, 2023 5:27 am
by Jasper

@Burunduk

Thank you so much, that was exactly what I was looking for.

Also, for the additional tip :thumbup2: