The is controlled by the HISTCONTROL variable. If is contains ignoredups, then duplicate commands will not be saved in the history. Without this string, they will be saved. This would be normally set in .profile or .bashrc, using something like
export HISTCONTROL=ignoredups
Other values that can be used in HISTCONTROL (multiple can be used, separated by :)
- ignorespace any commands starting with a space are not added to the history
- erasedups duplicate commands are erased from the history, so the history only contains the latest command
- ignoreboth identical to
ignoredups:ignorespace