Well, the thing I'm tired of clearing my terminal history again and again. So I was wondering if there's a way that the terminal doesn't record your history or the commands you've used.

If not, is there any way to do that?

I'm using Ubuntu 14.04 LTS.

Note: I use this command to clear terminal history:

cat /dev/null > ~/.bash_history && history -c && exit
  • 3
    What do you mean by clearing my terminal history? Why don't you want to have a history? Jul 3, 2015 at 11:43
  • 1
    @ArkadiuszDrabczyk In our office our account get audited, I sometime install tweaks and run some other commands which may be considered as unofficial, sometimes I forget to clear history. In this scenario, I need if there's alternative for it.
    – Kunal
    Jul 3, 2015 at 11:50

3 Answers 3


Single commands can be omitted from history (and up/down recall) by prepending with a space:

$ echo "foo"  # saved
$  echo "bar" # <-- not saved

Otherwise, you can turn off history by adding to ~/.bashrc:

set +o history

(to reenable, use set -o history)

If you want to disable it for the current session only:

$ unset HISTFILE
  • 1
    There's also some information here: commandlinefu.com/commands/view/7041/… This is an extension to @bertieb 's post above ('$ unset HISTFILE'). They are current session only changes.
    – James
    Jul 3, 2015 at 11:52
  • 1
    Single commands can be omitted from history (and up/down recall) by prepending with a space - only if $HISTCONTROL contains ignorespace Jul 3, 2015 at 11:55
  • 1
    @ArkadiuszDrabczyk or $HISTCONTROL contains ignoreboth, which 14.04 has set by default :)
    – bertieb
    Jul 3, 2015 at 11:57

Although this has been answered, I think this is also worth noting - if you wanted to, you could remove your .bash_history file, and add a symlink with the same name pointing to /dev/null. That would produce the same results - in fact, this solution is shell-agnostic (as long as you target the correct history file.

All you need is this:

ln -s /dev/null ~/.bash_history

Just don't do something like this and you'll be fine.

  • Oh my, that askubuntu question is so awkward, it hurts. (Upvoted your answer because using a symlink is a different approach that doesn't require one to edit login profile files.)
    – basic6
    Jul 9, 2015 at 10:59

It depends from the shell you are using. From the command you give it seems you are working with a bash shell. In this case you can both use




With the first one (HISTSIZE=) you put to zero the size of the history for the current shell. This means that after this command you will have no answer from history or pushing UP, CTRL+R... You can use HISTSIZE=0; exit to exit from the shell and clean the history of the current shell.

With the second one (HISTFILE=), a little shorter than all his variants (HISTFILE=/dev/null, unset HISTFILE... ), you will continue to have the history available in the current shell but it will not recordered when you will exit.

The built-in help history propose even

-c clear the history list by deleting all of the entries

In case you are using a zsh shell you can see this answer and the solution proposed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.