History

Asked by David Jones

How to remove history from terminal? When the command "history" is input I get an exhaustive list of commands ever entered as well as outputs. How do I delete them from my machine? Any help is greatly appreciated.

Thanking all of you in advance
   David
   in TN

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Marc Stewart
Solved:
Last query:
Last reply:
Revision history for this message
David Jones (dj) said :
#1

Sorry I am using Ubuntu 9.10

Revision history for this message
Larry Jordan (larryjor) said :
#2

     'history' is an integral part of Bash, and Linux for that matter. There is probably a way to clear it, or you can change the parameters so it doesn't keep track of quite so many commands.... I suppose you could write something else and call it history and then change your path variable so it finds your version of history first.... for the most part, history is used by those of us who use the terminal quite often and we wouldn't want to alter it. Maybe if I understood better what it is you are trying to accomplish?

Revision history for this message
David Jones (dj) said :
#3

 Thanks Larry Jordan what I am trying to do is delete the history stored by terminal commands. I see no purpose in every command being stored that seems a waste of resources. simply altering it to show "something else" is only storing more useless information.
What is the reason for keeping commands you have already ran in terminal?

  David
  in TN

Revision history for this message
GREG T. (ubuntuer) said :
#4

go to soft ware center and get bleachbit it will help you .

Revision history for this message
GREG T. (ubuntuer) said :
#5

the reason for the history is if you mess your system you have a place to look to see what you did , so you can fix it .

Revision history for this message
Best Marc Stewart (marc.stewart) said :
#6

To get rid of your bash history, go to your home folder and view the hidden files (Ctrl + H). Look for the unsurprisingly named:
.bash_history
You can edit this file manually in any text editor to remove specific commands, or just delete the file entirely.

Revision history for this message
David Jones (dj) said :
#7

Thanks Marc Stewart, that solved my question.

Revision history for this message
Larry Jordan (larryjor) said :
#8

      Ok, great, if all you wanted to do was to get rid of some past self-incriminating commands you issued.... By now, you may already be finding that it comes back.

      Type the following in a terminal:
                 echo $HISTSIZE

      You probably get some nice number like 10000 or 100000, right? Try this:
                 echo $HISTFILESIZE

       Same again?
      History is a shortcut for those who use it properly. Instead of retyping commands, you can call them back from the history file and execute them with the line number. So just typing "history" gives me:

 3966 echo $HISTSIZE
 3967 echo $HISTFILESIZE
 3968 history | grep echo

      From which, I could repeat those two commands with !3966 and !3967. Comes in handy if you are executing long commands over and over. If you're not using this feature or you would rather save the disk space for something else, you need to add something like this to your .bashrc file in your home directory:

export HISTSIZE=10 HISTFILESIZE=10

      That way, you will only save 10 commands. Please note, I'm assuming you are using the Bash shell; which reads .bashrc; if you are using a different shell it will be somewhere else. Hope this helps you to understand it all better, at least.