In gui mode, when a user has more than one terminal open, how do the terminals rewrite the history file of that user? the reason I ask is because, it is quite possible that in each of the terminals the user ends up executing different commands. So, does the history file end up saving the commands from all the terminals or only from the first one to be opened? Or is there some other kind of scheme that is employed to tackle this situation?
Mangled history
command history
It depends entirely on how the shell chooses to handle itbash by default will overwrite the history file with the local history of each shell as it exits, so the last shell to exit wins. The histappend option will cause it to append to the master history instead (shopt -s histappend).zsh does the same by default, and has a few options for dealing with it:appendhistory -- The history of each shell is appended to the master history file as the shell exitsincappendhistory -- The master history file is updated each time a line is executed in any shell, instead of waiting until that shell exitssharehistory -- Like incappendhistory, but also pulls changes from the master history file into all running shells, so you can run a command in one shell and then hit Up in another shell and see it