Byobu makes it easy to enable and disable automatic tmux sessions on login. If you are willing to install and use byobu as an interface to tmux to address this need, it makes it extremely simple to do what you are asking. In a terminal, run
sudo apt-get install byobu
From now on, when the root user logs in via the console, SSH, or with
sudo -i, byobu will attach to an existing tmux session or create a new one if one is not already running.
Note that I use
sudo -i instead of
sudo -s. The
-s option only starts a shell, not a login shell. You should use
sudo -i to emulate a full login, which also loads roots
~/.profile, and this is where byobu will install itself when you run
There are probably ways to do what you want with tmux alone, but byobu makes setting up and starting tmux automatically very simple.