Ask Your Question

How do I completely clear gnome terminal commands?

asked 2016-05-12 10:52:31 -0500

alexgachuhi gravatar image

I have tried running tput reset command, clear and even resetting the terminal from the terminal menu, but once i scroll back I still find the commands. How would I completely clear/delete all previous commands?

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2016-05-12 12:27:14 -0500

geforce gravatar image

Close all but the terminal you need to run this command.

rm ~/.bash_history;touch ~/.bash_history
edit flag offensive delete link more


Thank you:-)

alexgachuhi gravatar imagealexgachuhi ( 2016-05-12 12:44:09 -0500 )edit

wouldn't it be better to use && instead of ; ?

mikechav gravatar imagemikechav ( 2016-05-13 02:44:22 -0500 )edit

@mikechav - Probably more accurate to use &&, but I don't think the second entry is even required because ~/.bash_history (almost certainly) will be recreated automatically anyway.

In the current form, if the rm fails, the existing history file will have its time-stamp updated, instead of being recreated (presumably the intention of the touch command).

snowolfe gravatar imagesnowolfe ( 2016-05-14 07:16:40 -0500 )edit

@snowolfe I thought so too, but it doesn't hurt to be safe and recreate the file manually. But yeah, if rm fails, .bash_history won't be edited just through touch

mikechav gravatar imagemikechav ( 2016-05-24 08:00:22 -0500 )edit

answered 2016-05-13 22:22:16 -0500

mclmmc gravatar image

type history -c when you want wipe out your history

echo "history -c" >> $HOME/.bash_logout
echo "alias hv='history -c'" >> $HOME/.bashrc
edit flag offensive delete link more

answered 2016-05-14 07:34:39 -0500

snowolfe gravatar image

If your intent is to hide entries that contain passwords or other sensitive CLI data, but you still would like to keep the convenience of command-line history, then add HISTCONTROL=ignorespace to your bashrc file.

Whenever you enter a command that should be hidden from your history list, prefix it with a SPACE - it will not be added to the history file. If you accidentally add a sensitive entry, use history to find the entry ID and then history -d ID to remove it.

The advantages of history, but the security of not storing sensitive data in the history file!

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-05-12 10:52:31 -0500

Seen: 273 times

Last updated: May 14 '16