this is, because

this is, because, when one logs in, and opens another shell as the same user, the last bash process to quit, will save to

~/.bash_history

overwrite history.

to avoid this add: (TEST IN PROGRESS (UNTESTED)!)

# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups  
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend

# After each command, append to the history file and reread it
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

to:

# only for current user
~/.bash_profile
# system wide
/etc/bash.bashrc
# or
/etc/profile

in what order?

are those configs run? (src)

user@Debian8:~$ bash -l; # simulates a login
1. hello from /etc/bash.bashrc
2. hello from /etc/profile
7. hello from ~/.bash_profile
user@Debian8:~$ logout (Shortcut/Hotkey: Ctrl+D)
8. hello from ~/.bash_logout

user@suse12:~> uname -a; # tested with
Linux suse12 4.4.21-69-default #1 SMP Tue Oct 25 10:58:20 UTC 2016 (9464f67) x86_64 x86_64 x86_64 GNU/Linux

user@suse12:~> bash -l; # simulates a login
1. hello from /etc/bash.bashrc
3. hello from ~/.bashrc
2. hello from /etc/profile
7. hello from ~/.bash_profile
user@suse12:~> logout (Shortcut/Hotkey: Ctrl+D)
8. hello from ~/.bash_logout

[user@CentOS7 ~]$ uname -a; # tested with
Linux CentOS7 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
2. hello from /etc/profile
1. hello from /etc/bashrc
3. hello from ~/.bashrc
7. hello from ~/.bash_profile
[user@CentOS7 ~]$ Abgemeldet (Shortcut/Hotkey: Ctrl+D)
8. hello from ~/.bash_logout

Links:

https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows

https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html

admin