tmux is a “terminal multiplexer”, it enables a number of terminals (or windows) to be accessed and controlled from a single terminal. tmux is a great way to save an interactive session between connections you make to Linux servers, e.g. head nodes on the cluster.
You can reconnect to the session from a workstation in your lab or from your laptop from home!
To begin a
tmux session named myproject, type
tmux new -s myproject
You should see a bar across the bottom of your terminal window now that gives you some information about your session. If you are disconnected or detached from this session, anything you were doing will still be there waiting when you reattach
The most important shortcut to remember is Ctrl+b (hold the ctrl or control key, then type “b”). This is how you signal to
tmux that the following keystroke is meant for it and not the session you are working in. For example: if you want to gracefully detach from your session, you can type Ctrl+b, then d for detach. To reattach to our sample
tmux session after detatching, type:
tmux attach -t myproject #If you are lazy and have only one session running, #This works too: tmux a
Lines starting with a “#” denote a commented line, which aren’t read as code
Finally, to exit, you can type
exit or Ctrl+d