OSETC TECH

Linux: Disable Bash Shell Commands History

This post will guide you how to disable bash shell commands history on Linux system. How do I disable bash shell history in CentOS/Ubuntu Linux.

Get Current Commands History


If you want to display all commands history in Linux, you just need to type any of the following command:

#history

Or

#history |less

Or

#history | more

Check the Maximum Number of Commands saved in History


If you want to check the maximum number of commands saved in history in bash shell, you can print the history environment variable HISTSIZE to get it. Just type the following command:

#echo $HISTSIZE

Outputs:

root@ubuntu-dev:~# echo $HISTSIZE
1000

So the default value of the maximum history commands are save in history file is 1000. And the commands history list is save into the .bash_history file.

Disable Bash Shell History


If you want to disable bash shell history feature, you need to remove HISTFILE variable, then the history command is not able to write into the .bash_history file.

Type the following command:

#unset HISTFILE

Or

#echo “unset HISTFILE” >> ~/.bash_profile

Disable Bash History Permanently


If you want to disable bash history permanently, you can use the set command, type the following command:

#set +o history

Clear All History Commands


To clear all bash shell history commands in Linux, just type the following command:

#history –c