Skip to content

tmux terminal sessions ​

tmux provides multiple sessions, windows, and panes within SSH and can preserve remote terminal sessions after a local disconnect. It is useful for editing, compilation, job submission, and log monitoring. Start it on the node where the work belongs, after obtaining any required compute allocation.

Allocations still apply

A tmux session does not override Slurm time limits or resource rules. The node must remain available and the session must not be cleaned up.

Commands ​

CommandAction
tmuxStart a default session
tmux new -s NAMECreate a named session
tmux lsList sessions
tmux attach -t NAMEReattach by name or ID
tmux a -t NAMEShort form of attach
tmux detachDetach
tmux rename-session -t OLD NEWRename
tmux kill-session -t NAMEEnd a session

Shortcuts ​

Press Ctrl+b, release it, then press the second key.

Second keyAction
dDetach
%Split left/right
"Split top/bottom
Arrow keyMove between panes
cNew window
n / pNext / previous window
0–9Select window number
wChoose from window list
,Rename current window
&Close current window
xClose current pane

Basic workflow ​

Start a default or named session:

bash
tmux
bash
tmux new -s work

A status bar appears at the bottom:

Interface illustration

Split into panes:

bash
tmux split-window      # Split top/bottom
tmux split-window -h   # Split left/right

Interface illustration

Detach while leaving the session running:

text
Ctrl+b, d

On reconnecting to the same node, list sessions:

bash
tmux ls

Interface illustration

Reattach using a session ID or name:

bash
tmux attach -t 1
bash
tmux a -t 1

Interface illustration

Named sessions and logs ​

Choose distinct names for different tasks:

bash
tmux new -s train
tmux new -s build
tmux new -s analysis

Reconnect by name:

bash
tmux a -t train

Follow a job log:

bash
tail -f job.out

Detach with Ctrl+b, d, then return later with tmux ls and tmux a -t NAME.

Troubleshooting and exit ​

Sessions survive a local SSH disconnect only while the remote node and session remain active. If a session is missing, check that you returned to the node on which it was created. For a temporary departure, detach; to close the shell/pane, enter:

bash
exit

Or end an entire session from another shell (replace the Chinese placeholder with its name or ID):

bash
tmux kill-session -t <会话名或编号>

Official tmux project

Copyright 2021 Biodesign Center. All rights reserved.