Why, after a Ubuntu 14.04 software update, does have exec tmux in my .bashrc lead to not being able to log in (though previously it worked fine for years) and how to fix ?


I recently did a Ubuntu 14.04 update and then couldn't even log in to the system at all. Only the fact that I once created another account on this machine (so do that now yourself! have the account have little to no .bashrc stuff) made fixing it relatively easy. Having previously made an extra account that has admin saved me. Also the fact that I can log into that account and then when doing

su other_account_name  

- Which initially still fails as it tries to use .bashrc -

I can actually do

su other_account_name -s /bin/sh 

instead to just use the basic sh shell and avoid bash.
Then I can edit the bashrc and fix what's wrong, save the file and all is restored. Phew!

Investigation complete. Back to the question...

So, after all this, I finally tracked down the issue to the fact that having exec tmux in my .bashrc using

[ -z "$TMUX" ] && command -v tmux > /dev/null && TERM=xterm-256color && tmux

was messing up logging in initially.

However, if I'm already logged in, that allows new windows (that have tmux activated) to be created without a problem.

How to fix and be able to use tmux and have my .bashrc still work for initial login?


  • I can do exec tmux after logging in and it gets activated and I can use it ok.
  • I tried changing exec tmux to tmux in the line in .bashrc and it 'half' helped - I get an 'invalid' message popup* when I log in to the account - but tmux has been invoked and is usable.
  • I checked and I seem to have a current version - 1.9a - of tmux
  • The popup that I get when I changed my ./bashrc to have tmux instead of exec tmux contains:

    Error foud when loading /home/durrant/.profile:\n\n open terminal failure: not a terminal\n\n As a result the session will not be configured correctly.
    You should fix the problem as soon as possible.

  • I've also tried having


on its own line in my .bashrc file and also having

[ -z "$TMUX" ] && tmux

but got the same errors

  • There are so many issues with this approach: first, .bashrc is read every time you open a shell, second, the TERM variable inside tmux has to be set to screen*, and third, your overall approach is just wrong: spawn a tmux session on login and then open shells in that, not the other way around...
    – jasonwryan
    Commented Feb 28, 2015 at 19:33

1 Answer 1


Currently, as I have not found an actual fix, my temporary workaround is to not invoke tmux in my .bashrc.

I've created an alias t for tmux so that once I open a terminal window I can just type t[return] to enable tmux for that session.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .