It's possible your $HISTFILE is owned by root. Assuming your are using bash as your login shell. Here's how to check:
$ [ -z $HISTFILE ] && echo need to set HISTFILE || ls -l $HISTFILE
-rw------- 1 root root 36639 May 21 19:48 /home/joeb/.bash_history
The default for HISTFILE should be ~/.bash_history, if you see the error "need to set HISTFILE" or if $HISTFILE is not ~/.bash_history, then you should check ~/.profile or ~/.bash_profile or ~/.bashrc to make sure it's not getting set or reset incorrectly.
Normally, it's just owned by root, so just reset it:
$ chown joeb.joeb $HISTFILE
$ ll $HISTFILE
-rw------- 1 joeb joeb 36639 May 21 19:48 /home/joeb/.bash_history
Logout then login.
$ history
Should show the last set of commands entered before the file was owned by root, followed by the commands entered after the file ownership was changed.
Is this still a valid answer? In my system, there is an entry
shopt -s histappend
under/etc/bash/bashrc
. Still, any unclean exit of running shells, loses its command line history. – Nikos Alexandris – 2019-02-19T01:07:25.343