0

I had been working with multiple terminal opened . For some reason my PC rebooted and after when I executed the 'history' command , I could only see the list of commands related to a particular terminal.

Is there any way of getting all histories of all opened terminals .

0

You cannot get the other histories back. All your terminals wrote to your history file, and it sounds like you either had too small of a HISTFILESIZE value set or you don't have shopt -s histappend set to append to the HISTFILE instead of overwriting it. In either case, each terminal wrote to the HISTFILE in sequence and the list of commands you have left is from the final terminal to do so.

If you want to avoid this in the future, you can set (in your .bashrc)

shopt -s histappend #append to history file instead of overwriting
HISTFILESIZE=10000 #increase number of stored commands in HISTFILE

This will save all your commands grouped by terminal session when you restart. If you'd rather them be time-ordered, you can use this as well:

#logs every command as it is written to the history file, 
#and updates local terminal history to match
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.