Minimum commands to survive tmux

tmux is a terminal multiplexer. It is very useful when we need run long-running tasks on remote servers on the background and check the results later without the need to keep a constant live ssh connection and worrying about network failure causing the task to exit unexpectedly. Here is a list of minimum commands to meet most of the use cases.

List existing sessions

# list existing sessions
$ tmux ls

Create a new session

# create a new session
$ tmux new -s <session-name>

Detach an existing session (i.e. put to background)

# hold ctrl, press b, release both, and then press d
$ ctrl+b d

# in case of nested session - not recommended
# hold ctrl, press b, release both; repeat, and then press d
$ ctrl+b ctrl+b d

Attach an existing session (i.e. bring to foreground)

# attach to an existing session
$ tmux attach -t <session-name>

Kill an existing session

# kill an existing session
$ tmux kill-session -t <session-name>

linux