tmux – a “terminal multiplexer” – lets you control several windows to the command line from one terminal session. Additionally you can leave tmux and close the terminal – this is very handy, if you have long running programs, and have to leave the office.
So let’s start tmux:
The screen is not very spectacular – you hear a little ping and you see a prompt and a status line.
Now we start a long running job, i.e.:
while true do date sleep 10 done
Ctrl-B is the “prefix key” and is used to introduce the tmux commands.
d is the command to detach from the tmux session.
Now get a cup of tea, go outside or just wait some minutes.
If you come back to the terminal, type
$ tmux ls
This lists all active tmux sessions. If there is only the one you left, this session will have the number 0. You can attach to this session with
$ tmux attach -t 0
and we see, that our little “program” worked all the time.
Use this e.g. for database updates, backup jobs, or log file analysis.