Tmux
tmux is a terminal multiplexer. It's a good tool for e.g. remote support. It can also be used to start a command you want to keep running after you close your console session (you can later on attach to your running session).
Install
In order to use tmux you will have to install it:
apk add tmux
Usage
Start a new session
To create a tmux session you just enter:
tmux
List existing sessions
When you have started some session(s) you can list them:
tmux ls
tmux list-sessions
You might get a list that looks like this:
0: 1 windows (created Wed Oct 24 15:12:12 2012) [126x35] 1: 1 windows (created Wed Oct 24 15:14:44 2012) [126x35]
Attach to a existing session
Lets say you want to attach to a existing session (e.g. the above 1: 1 windows
session).
tmux attach -t 1
tmux attach
Controlling a session
While inside a tmux session, you can control it using keyboard shortcuts. We will only describe some of those alternatives.
In the below examples this procedure is described as
C-b
Get help
One of the most useful commands is the one that gives you 'help'.
While in your tmux session, click:
C-b ?
(Do not press/hold CTRL when clicking ?)
Detach from a session
Sometimes it's useful to just detach from a session without killing it.
C-b d
ping 127.0.0.1
while inside a session and then detach from the session.After some while re-connect to the session using
tmux attach
.Note that the "seq" value indicates that ping had continued running while you where detached from the session.
Close or kill a session
To 'kill' a session:
C-b &
Confirm by clicking y when prompted.
You can also 'kill' your session by entering:
exit