How to logout from shell without saving bash history

bash history
bash history

Logout from shell without saving bash history

Here I am explaining different methods to logout from shell without saving bash history.

Method 1


Run the above command before loging out from the server to exit from terminal without saving bash history.

Method 2

kill -9 $$

The above command will kill the current terminal without saving the history.

Method 3


The above command will change the HISTSIZE to zero. Hence it can’t store the current history.

Method 4


This command also clears the current session history.

Method 5

history -c

It will delete the all bash history. i.e., the earlier history will be removed.

Method 6

If you would like to avoid only some commands in the history file, you can set the HISTIGNORE variable.


Any instance of cat and cd will not be recorded on your bash history if you use the above command.

Method 7

Also, if you would like to avoid some particular commands, you can set HISTCONTROL variable.


By setting the above command will help to omit any command lines starting with space.


It will skip repeated lines.

That’s it!

If you like this post and wish to receive more articles from us, please like our FB page: Grepitout

Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.

For more details on our services, please drop us an E-mail at