What is HISTCONTROL?
HISTCONTROL variable is a colon-separated list of values controlling how commands are saved in the history list. HISTCONTROL variable allows us to store the bash history more efficiently. It can be used to ignore the duplicate commands or commands with leading white space or both.
How to prevent bash history?
How to Remove/ Disable Bash shell Command History on Linux
- Disable history for a current shell. # set +o history.
- Clean command history. # history -c.
- Permanently disable bash history. # echo ‘set +o history’ >> ~/.bashrc.
- Disable a command history system wide:
What is the use of histcontrol in Bash?
HISTCONTROL variable allows us to store the bash history more efficiently. It can be used to ignore the duplicate commands or commands with leading white space or both. Uses of HISTCONTROL command: Several commands are executed multiple times while working at the command line.
What does ignoreboth do in Bash history list?
A value of ignoreboth is shorthand for ignorespace and ignoredups. A value of erasedups causes all previous lines matching the current line to be removed from the history list before that line is saved.
How to prevent commands from showing up in Bash history?
If you’ve set the HISTCONTROL environment variable to ignoreboth (which is usually set by default), commands with a leading space character will not be stored in the history (as well as duplicates). A colon-separated list of values controlling how commands are saved on the history list.
How to ignore commands that start with spaces in Bash?
The ignorespace flag tells bash to ignore commands that start with spaces. The other flag, ignoredups, tells bash to ignore duplicates. You can concatenate and separate the values with a colon, ignorespace:ignoredups , if you wish to specify both values, or you can just specify ignoreboth .