Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why do I get different results for the "history" command for the same user after I reconnect a disconnected SSH session?

  • I connect to a server using putty (SSH), say as root
  • My network gets disconnected
  • I reconnect my putty session
  • When I hit my up arrow key to re-run the last used command, it shows a different command

I am guessing this is due to getting reconnected to a different pts. Am I right?

share|improve this question
    
Possible duplicate: Preserve bash history in multiple terminal windows –  slm May 10 '13 at 8:34
add comment

1 Answer

There are several environment variables that control history's behavior. Some of them include:

HISTFILE=/home/saml/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000

Typically what happens is that you have more than one shell open and which ever shell get's closed last clobbers some of the entries that were written there previously by the shell that you closed first.

Take a look at the Bash Reference Manual's section on the history command for more info.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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