Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Delete Terminal history?

  1. #1
    Join Date
    Nov 2009
    Beans
    616

    Delete Terminal history?

    How do I easily and permanently delete the Terminal history (all of the stuff I've typed in Terminal)?

    Thanks

  2. #2
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,376
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Delete Terminal history?

    [Alt]+[F2]
    Code:
    rm ~/.bash_history
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

  3. #3
    Join Date
    Nov 2009
    Beans
    616

    Re: Delete Terminal history?

    I tried your commands but when I type "history" I still see all of the commands I've entered.

    Any ideas?

  4. #4
    Join Date
    Jun 2009
    Location
    0:0:0:0:0:0:0:1
    Beans
    4,376
    Distro
    Xubuntu 13.04 Raring Ringtail

    Re: Delete Terminal history?

    if the terminal was open when you ran that that is expected, new windows should be empty
    if you run rm ~/.bash_history in a termnal and type exit yuor history will have exit and rm ~/.bash_history
    Laptop: ASUS A54C-NB91 (Storage: WD3200BEKT + MKNSSDCR60GB-DX); Desktop: Custom Build - Images included; rPi Server
    Putting your Networked Printer's scanner software to shame PHP Scanner Server
    I frequently edit my post when I have the last post

  5. #5
    Join Date
    Jan 2012
    Beans
    753

    Re: Delete Terminal history?

    Every time you exit a Terminal session, it saves the history to ~/.bash_history (that's to prevent multiple Terminal instances' history from interfering). So if you have a lot of history and then do "rm ~/.bash_history" but then you exit, everything you typed into the current session (including "rm ~/.bash_history") will be saved to a new history file. You have to do this to remove it all:
    1) Exit any of your current Terminal sessions (which saves it to ~/.bash_history)
    2) Open a new Terminal session and run "rm ~/.bash_history"
    3) Exit that session

    That should work. One thing I do if I don't want everything I typed in one session to be saved is I run "kill -9 $$" instead of exit. That forcibly kills the bash process and causes it to crash and close Terminal without saving history, while still preserving history from past sessions (kind of like an "incognito mode" for Terminal). I wouldn't always recommend that though because it kills bash, so if bash is trying to save anything that data might be corrupted, though I've never had a problem.
    Last edited by Stonecold1995; November 15th, 2012 at 06:06 AM.

  6. #6
    Join Date
    Oct 2008
    Beans
    3,509

    Re: Delete Terminal history?

    Edit: ALREADY SAID.

  7. #7
    Join Date
    Aug 2011
    Location
    52° N 6° E
    Beans
    2,810
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Delete Terminal history?

    If you issue the command
    Code:
    HISTFILE=
    during your session the history won't be saved either. I thinks it's a cleaner way. Putting
    Code:
    export HISTFILE=
    in your .bashrc file disables your history permanently.

  8. #8
    Join Date
    Oct 2009
    Location
    Reykjavík, Ísland
    Beans
    10,400
    Distro
    Lubuntu 14.10 Utopic Unicorn

    Re: Delete Terminal history?

    I believe that you can just type

    Code:
    history -c
    but I'm not on Buntu now so can't test it.
    About problems due to upgrading
    Bringing old hardware back to life.
    Please visit Quick Links -> Unanswered Posts

  9. #9
    Join Date
    Nov 2012
    Beans
    9

    Re: Delete Terminal history?

    Quote Originally Posted by mörgæs View Post
    I believe that you can just type

    Code:
    history -c
    but I'm not on Buntu now so can't test it.

    Yep it'll work. That's a built-in of the bash shell so it doesn't matter what distro it is, as long as bash is the login shell.

  10. #10
    Join Date
    Jun 2007
    Beans
    13,879

    Re: Delete Terminal history?

    history -c will only 'delete' the history of the current open terminal not clear ~/.bash_history

    As mentioned just delete ~/.bash_history

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •