Display current history
Just type the history command:
history | less
history | more
history | grep 'find'
How to find out the number of commands saved in the history
Use echo command or printf command :
printf "%d\n" $HISTSIZE
The value of the HISTSIZE variable indicates that the 1000 number of commands saved in a history list.
Where are my bash history commands stored
The history is initialized from the file named by the variable HISTFILE. The default is the ~/.bash_history file. To view current settings run:
printf "%s\n" "$HISTFILE"
How to disable BASH shell history on Linux or Unix
You can remove HISTFILE shell variable by typing the following unset command:
Add above line to the end of to a new /etc/profile.d/disable.history.sh file or ~/.bash_profile:
echo 'unset HISTFILE' >> /etc/profile.d/disable.history.sh
echo 'unset HISTFILE' >> ~/.bash_profile
How to permanently disable bash history using set command
Another option is to pass the "+o history" option to the set builtin command:
set +o history
Again add "set +o history" to the end of to a new /etc/profile.d/disable.history.sh file or ~/.bash_profile. See how to set and use shell option in bash for more info.
How to clear the bash history
Type the following command in your current session:
To delete a single command number 42 from history in Linux/Unix:
history -d 42