Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I am running 12.04 server and when I type history in bash I see most of the commands I have entered into bash but I don't see the commands I have entered when in a tmux session.

How do I see the history of the commands I have run inside a tmux session on Ubuntu 12.04 server after I have ended the session?

share|improve this question
So, you want to see the history of the commands that you ran inside tmux in your bash terminal? – Radu Rădeanu Aug 31 '13 at 17:50
If you are referring to the history of bash inside of tmux, and said shell is still running, you will have to add some settings to your ~/.bashrc and ~/.bash_login to make history append to the file while running. – demure Aug 31 '13 at 22:03
@demure I am referring to the history of a bash shell that was inside tmux but tmux and the bash shell that was running in tmux are both no longer running. – Chris Magnuson Aug 31 '13 at 23:31
@RaduRădeanu When I type tmux at bash and get a new bash shell, run ls and then exit, I am now back at the first bash shell and the history command shows that I ran tmux but not that I ran ls. – Chris Magnuson Aug 31 '13 at 23:33
up vote 8 down vote accepted

You have to preserve bash history in multiple bash shells. To do this, be sure that you have the following lines in your ~/.bashrc file:

# avoid duplicates..
export HISTCONTROL=ignoredups:erasedups

# append history entries..
shopt -s histappend

# After each command, save and reload history
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"


share|improve this answer
I tired this out on 12.04 Ubuntu server and now each time I type the history command my history number increments by 40. I typed history in the shell three times and my last command number went from 1305 to 1345 to 1385 to 1425 and so on. Why is this happening? – Chris Magnuson Sep 7 '13 at 20:33
@ChrisMagnuson This doesn't happen at me. Anyway, this is a different question toward your original question. So, don't hesitate to use Ask Question button. – Radu Rădeanu Sep 7 '13 at 20:45

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.