Command history across multiple PuTTy sessions in SunOS 5.10

1

I have multiple PuTTy sessions open to my SunOS 5.10 server, and I am using ksh, and SOMETIMES the command history is shared among the different sessions and SOMETIMES it is not. I cannot figure out what determines whether it is or is not shared. By shared what I mean is that a command run in one session will be seen as previous command run in another session.

I prefer it not to be shared, is there a config setting for that?

amphibient

Posted 2012-09-21T15:33:20.633

Reputation: 1 613

Answers

2

Most Unix shells read old history from a file, once – when the shell is started – and when you close that shell, the history is written to the file again.

Usually the old contents are simply overwritten, so if you do something like...

  1. login to sessions A and B
    • A and B read the same contents of ~/.history
  2. run command test in A
    • A adds test to its in-memory history
    • B doesn't know about the command
  3. logout from A
    • A overwrites ~/.history with its history, which has test
  4. login to session C
    • C reads contents of ~/.history, with test
  5. logout from B
    • B overwrites ~/.history with its history, which doesn't have test
  6. logout from C
    • C overwrites ~/.history with its history, which has test

then test will be saved to the history file after step #3, but step #5 will discard it, and step #6 will add it again...

Some shells have an "append history" option that avoids this (e.g. shopt -s histappend in Bash).

If you want to have completely separate histories, an easy way is to just symlink your history file to /dev/null.

user1686

Posted 2012-09-21T15:33:20.633

Reputation: 283 655