how to enable command history of shell
At a Bash prompt, type the following commands and do the steps listed after each one:
set -o | grep history
If you get "history off" then add this line at the end of your ~/.bashrc
:
set -o history
Next try:
echo $HISTFILE
echo $HISTSIZE
echo $HISTFILESIZE
If the first one is blank or /dev/null
, add this line to the end of your ~/.bashrc
:
HISTFILE=$HOME/.bash_history
If either of the last two print 0, set them to some number like the default of 500:
HISTFILESIZE=500
HISTSIZE=500
Do not forget to source .bashrc
after saving ~/.bashrc