When you start a new session in tmux or create a new window inside a running session, its default behavior is to run a shell (ex.: bash) as a "login shell".

I understand that a login shell is intended to execute a routine of configurations and procedures that are of interest just when you are logging in a system. But in the majority of the cases (with the exception that you can use tmux as a login shell) it’s not the true intent of the user to do this when they just wants to open a new window.

So what is the rationale for making this the default behavior of tmux?

The only thing the documentation says about the matter:

default-command  shell-command
        Set the command used for new windows (if not specified when the
        window is created) to shell-command, which may be any sh(1)
        command.  The default is an empty string, which instructs tmux
        to create a login shell using the value of the default-shell

2 Answers 2


Interactive non-login shell usually never outlive your top level login shell, therefore they can expect any facilities started by it to be available anytime, but this is not the case with tmux:

  • you log in to your shell -> your login scripts are run
  • you run tmux, do something, detach
  • exit your top level shell -> your logout scripts are run
  • tmux session is still running but any facilities started by your login shell are not available at this time
  • you log in again and re attach from another login shell
  • any facilities started by the new login shell may not be visible by tmux because it is still running with the old environment (even though there are commands to update the environment)

Some may think having tmux start login shells is unnecessary anyway because in most setups there are no logout scripts, and login scripts just set up some environment variables.

Furthermore if you append strings to your environment variables in your login scripts (like this: PATH=$PATH:/some/other/path) and they are run more than once in the same process hierarchy you end up with duplicates, and this is most annoying.

But still I tend to think the default makes sense.

See also this: http://openbsd-archive.7691.n7.nabble.com/tmux-and-login-shells-td170948.html

  • 2
    Thank you for the answer and for the link! I think I can live with exec sh in the end... (I had not thought of that.)
    – leogama
    Sep 10, 2015 at 6:30
  • 5
    Do you have any concrete examples of things that could break if tmux didn't spawn a log-in shell? I'm thinking of making that my default, but I don't want to run into hard-to-diagnose problems down the line. Dec 15, 2016 at 2:04
tmux attach-session

Will not create a new login by default, so it makes sense that


will always create a new shell by default else it wouldn't have a shell to work with if none existed already. As such if you delete the newly created shell tmux immediately exits.

Better use tmux resurrect &/ continuum via the tmux plugin manager to keep your place whenever you reconnect to a shell e.g using ssh However they also depend on tmux and it's default behavior.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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