One of my favourite utilities ever is tmux, no doubts about it. It allows you to create a session when you are connected to a machine via SSH and restore that session later even if your SSH connection drops for any reason. Once you reattach the session, you will be brought back exactly to the point where you were before the disconnection.
This is extremely useful in cases where the command you launched would take a long time to complete (for example, if you are burning in your hard drives for FreeNAS or if you are generating DH parameters when configuring OpenVPN).
However, Raspbian Lite does not come with tmux installed by default, you will have to do it yourself, and take care of some locale configuration to avoid issues.
Installing tmux on Raspbian
Easy as pie:
sudo apt-get install tmux
This will install all necessary dependencies too, so you don’t have to worry about that either.
Configuring locale settings
If you haven’t configured locale settings in Raspbian, tmux will complain the first time you launch it:
tmux: invalid LC<em>ALL, LC</em>CTYPE or LANG
To solve this, simply run
sudo dpkg-reconfigure locales
, choose one locale and select OK to complete the configuration.
To create a tmux session, SSH to your Raspberry Pi and type
To reconnect to an existing session later on, connect to your Raspberry Pi again and type
This was a quick tutorial to get tmux installed and working on Raspbian. tmux is an extremely useful utility that I recommend installing on your Raspberry Pi, especially if you plan on launching commands that might take a long time to complete. However, even in normal use, it might be a good idea to install the tool anyway – you never know when the next network disconnection might happen ;)