
A typical problem when connecting to a remote machine is that if the connection drops, the remote server will believe we are no longer interested in it and will kill our session. If we were performing some analysis, it would be terminated and we’d have to run it again.
Sometimes the analysis is long, and even if we have a stable connection we need to keep our computer on
just to let the remote server know we don’t want to close the session.
There is a handy tool to make our life easier: tmux.
With tmux we can create a terminal that will not disappear when we disconnect from a machine,
and that will wait for us to come back when reconnecting to the server.
In this section, we’ll see how to
First of all, we have to check that no other tmux session is active:
tmux ls
tmux new -s course
With the -s switch we gave our session a handy nickname (“course”), but it’s not mandatory to do so, but can be very helpful.
tmux attach -t course
Since tmux shows us a Linux terminal, when we type we are talking to the terminal itself. So to interact with tmux we need a special shortcut: Ctrl + b. This triggers tmux to listen to us. Then we can type a second key to specify what we needed:
Ctrl + b, c to create a new window inside our sessionCtrl + b, p to navigate to the previous windowCtrl + b, n to navigate to the next windowCtrl + b, d to detach from the session: we’ll return back to the “parent” terminal where we can reattach to the tmux session with tmux attach -t course.For more information you can read this guide or this introduction to tmux.