TMUX QUICK REFERENCE tmux keeps terminal sessions running after an SSH connection closes and allows multiple windows and panes inside one terminal. The default command prefix is: Ctrl+B Press Ctrl+B, release both keys, and then press the command key. MOST-USED COMMANDS Start or attach to a named session: tmux new -A -s work List existing sessions: tmux ls Attach to a session: tmux attach -t work Detach from the current session: Ctrl+B, then D Create a new window: Ctrl+B, then C Next window: Ctrl+B, then N Previous window: Ctrl+B, then P Choose a window: Ctrl+B, then W Split into left and right panes: Ctrl+B, then % Split into top and bottom panes: Ctrl+B, then " Move between panes: Ctrl+B, then Arrow key Temporarily maximize the current pane: Ctrl+B, then Z Close the current pane: Ctrl+B, then X Enter scrollback and copy mode: Ctrl+B, then [ Exit copy mode: Q Show all keyboard shortcuts: Ctrl+B, then ? COMMON VPS WORKFLOW Start a persistent session: tmux new -A -s work Run commands normally inside tmux. Detach before closing SSH: Ctrl+B, then D Reconnect to the VPS later and list sessions: tmux ls Reattach: tmux attach -t work STARTING AND ATTACHING Create a named session: tmux new -s work Create the session or attach if it already exists: tmux new -A -s work Create a detached session: tmux new -d -s work Create a detached session running a command: tmux new -d -s build "dotnet build" List sessions: tmux ls Attach to a named session: tmux attach -t work Attach to the most recently used session: tmux attach Detach another client and attach the session here: tmux attach -d -t work Check whether a session exists: tmux has-session -t work Show the installed tmux version: tmux -V SESSION COMMANDS Ctrl+B, D Detach from the current session. Ctrl+B, S Display an interactive session tree. Ctrl+B, $ Rename the current session. Ctrl+B, ( Switch to the previous session. Ctrl+B, ) Switch to the next session. Ctrl+B, L Switch to the previously used session. Kill a named session from the shell: tmux kill-session -t work Kill every tmux session: tmux kill-server WINDOWS A window occupies the full terminal and may contain one or more panes. Ctrl+B, C Create a new window. Ctrl+B, N Move to the next window. Ctrl+B, P Move to the previous window. Ctrl+B, L Move to the previously used window. Ctrl+B, 0 through 9 Select a window by number. Ctrl+B, W Display an interactive session and window tree. Ctrl+B, , Rename the current window. Ctrl+B, & Close the current window after confirmation. Create a window from the shell: tmux new-window -t work Create and name a window: tmux new-window -t work -n logs Rename a window from the shell: tmux rename-window -t work:1 logs List all windows: tmux list-windows -a PANES A pane is an individual terminal inside a window. Ctrl+B, % Split the current pane into left and right panes. Ctrl+B, " Split the current pane into top and bottom panes. Ctrl+B, Arrow key Move to the pane in that direction. Ctrl+B, O Move to the next pane. Ctrl+B, ; Move to the previously active pane. Ctrl+B, Q Display pane numbers. Press a displayed number to select that pane. Ctrl+B, Z Zoom or unzoom the current pane. Ctrl+B, X Close the current pane after confirmation. Ctrl+B, { Swap the current pane with the previous pane. Ctrl+B, } Swap the current pane with the next pane. Ctrl+B, Space Cycle through the available pane layouts. Ctrl+B, ! Move the current pane into its own window. Ctrl+B, Ctrl+Arrow Resize the pane one cell at a time. Ctrl+B, Alt+Arrow Resize the pane in larger steps. Some terminals and desktop environments may intercept Ctrl or Alt arrow combinations. List all panes: tmux list-panes -a COPY MODE AND SCROLLBACK Ctrl+B, [ Enter copy mode and inspect terminal history. Arrow keys Move through the history. Page Up and Page Down Move one page at a time. Q Exit copy mode. Ctrl+B, ] Paste the most recently copied tmux buffer. Copy-mode selection keys depend on whether tmux is using Emacs-style or vi-style controls. Press Ctrl+B, then ? to inspect the current bindings. COMMAND PROMPT Ctrl+B, : Open the tmux command prompt. Useful commands entered at the prompt: new-window Create a new window. rename-window name Rename the current window. rename-session name Rename the current session. split-window -h Split into left and right panes. split-window -v Split into top and bottom panes. resize-pane -L 5 Resize five cells toward the left. resize-pane -R 5 Resize five cells toward the right. resize-pane -U 5 Resize five cells upward. resize-pane -D 5 Resize five cells downward. source-file ~/.tmux.conf Reload the configuration file. TARGETS tmux identifies sessions, windows, and panes using this general format: session:window.pane Examples: work The session named work. work:1 Window 1 in the work session. work:1.0 Pane 0 in window 1 of the work session. RUNNING COMMANDS FROM OUTSIDE TMUX Send a command to a pane and press Enter: tmux send-keys -t work:1.0 "docker compose ps" Enter Capture the visible contents of a pane: tmux capture-pane -p -t work:1.0 Capture the last 100 lines of pane history: tmux capture-pane -p -t work:1.0 -S -100 Create a detached build session: tmux new-session -d -s build "dotnet build" Create or attach to a session: tmux new-session -A -s work AFTER AN SSH DISCONNECT Reconnect to the server and list sessions: tmux ls Attach to the session: tmux attach -t work Programs inside the session continue running while tmux is detached, provided that the server and tmux process remain running. MINIMAL CONFIGURATION tmux reads personal configuration from: ~/.tmux.conf A small useful configuration: set -g mouse on set -g history-limit 50000 Mouse support allows selecting panes, resizing panes, changing windows, and scrolling through terminal history. Reload the configuration from the shell: tmux source-file ~/.tmux.conf Reload it from inside tmux: Ctrl+B, then : Enter: source-file ~/.tmux.conf HELP AND DIAGNOSTICS Display all current keyboard bindings: Ctrl+B, then ? Open the tmux command prompt: Ctrl+B, then : Read the manual: man tmux List all key bindings: tmux list-keys Show global session options: tmux show-options -g Show global window options: tmux show-options -gw Display server information: tmux info IMPORTANT DISTINCTION tmux keeps interactive programs alive across terminal and SSH disconnects. Permanent production services should normally be managed by systemd, Docker Compose, or another service manager rather than being left running inside tmux. .