Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My home directory is mounted on an NFS mount. The commands I use on one machine are usually quite different to those on another. Is it possible to have easy host write to it's own history file?

share|improve this question
up vote 14 down vote accepted

It certainly is. You just have to change the name of your history file on each host. In your .bash_profile put something like:

export HISTFILE="${HOME}/.bash_history.`hostname`"
share|improve this answer
My bash wouldn't expand ~, so I had to use ${HOME} export HISTFILE="${HOME}/.bash_history.$(hostname)" – brianegge Dec 14 '09 at 23:16
Thanks, modified the answer. – Kamil Kisiel Dec 15 '09 at 23:35

There is the environment variable HISTFILE, which controls where the history file is. You could try to create a login script that resets HISTFILE according to your hostname/IP.

share|improve this answer

Your Answer


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.