tmux
하나의 terminal에서 여러 shell과 program을 session, window, pane으로 구성하고 detach 후 다시 attach할 수 있는 terminal multiplexer.
Summary
- server가 session, window, pane 상태를 유지하고 client가 terminal을 통해 attach한다.
- SSH 연결이 끊겨도 session 안의 process를 계속 실행할 수 있다.
- 기본 prefix는 Ctrl+B이며, prefix 다음에 command key를 누른다.
- shell command와 tmux command prompt에서 같은 tmux command를 사용할 수 있다.
Installation
# Debian / Ubuntu sudo apt update sudo apt install tmux # Fedora sudo dnf install tmux # RHEL / CentOS sudo yum install tmux # macOS Homebrew brew install tmux # 설치 확인 tmux -V
- upstream 설치 문서는 Arch Linux, openSUSE, MacPorts와 source build 방법도 안내한다.
- distribution package는 최신 upstream release보다 오래된 version일 수 있다.
- upstream 설치 문서에는 Windows native 또는
winget설치 방법이 안내되지 않는다. Windows에서는 WSL의 Linux distribution 안에 설치하는 방식을 고려한다.
Usage
tmux [GLOBAL_OPTIONS] [COMMAND [COMMAND_OPTIONS] [ARGS...]]
tmux [GLOBAL_OPTIONS] [COMMAND] [COMMAND_OPTIONS] [ARGS…]tmux new-session -s NAMEtmux attach-session -t NAMEtmux split-window [-h|-v]
Options
Global Options
-f FILE: 기본 config 대신 지정한 file을 읽는다.-L SOCKET_NAME: 별도 server socket 이름을 사용한다.-S SOCKET_PATH: server socket의 전체 경로를 지정한다.-V: tmux version을 출력한다.-v: verbose logging을 사용한다. 반복하면 verbosity가 증가한다.
각 tmux command의 option은 command 뒤에 둔다. 예를 들어 session 이름을 지정하는
-s는 new-session의 option이다.
Commands
Session
tmux new-session [-AdDEPX] [-s NAME]: 새 session을 만든다. alias는new다.tmux attach-session [-dErx] [-t TARGET_SESSION]: 기존 session에 attach한다. alias는attach다.tmux list-sessions: session 목록을 표시한다. alias는ls다.tmux rename-session -t TARGET_SESSION NEW_NAME: session 이름을 바꾼다.tmux kill-session -t TARGET_SESSION: 지정한 session을 종료한다.
Window and Pane
tmux new-window [-dn] [-n NAME]: 현재 session에 window를 만든다. alias는neww다.tmux list-windows [-t TARGET_SESSION]: window 목록을 표시한다. alias는lsw다.tmux split-window [-hv] [-t TARGET_PANE]: pane을 위아래 또는 좌우로 나눈다. alias는splitw다.tmux select-pane [-UDLR] [-t TARGET_PANE]: active pane을 바꾼다.tmux resize-pane [-UDLR] [ADJUSTMENT]: pane 크기를 조절한다.tmux kill-pane [-t TARGET_PANE]: 지정한 pane을 종료한다.
Inspect and Control
tmux list-commands: 지원 command와 signature를 표시한다. alias는lscm이다.tmux list-keys [-T KEY_TABLE]: key binding을 표시한다. alias는lsk다.tmux display-message -p FORMAT: format을 평가해 출력한다.tmux source-file PATH: config file을 다시 읽는다. alias는source다.
tmux kill-server는 해당 server의 모든 session과 그 안의 process를 종료한다. 먼저 tmux ls로 대상을 확인하고, 단일 session만 닫을 때는 kill-session -t NAME을 사용한다.
Examples
Create or Attach
# work session이 있으면 attach하고 없으면 생성 tmux new-session -As work # background에서 session 생성 tmux new-session -d -s build # session 확인 및 attach tmux list-sessions tmux attach-session -t build
Window and Pane
# 이름이 logs인 window 생성 tmux new-window -n logs # 좌우 분할 tmux split-window -h # 위아래 분할 tmux split-window -v # pane 목록과 id 확인 tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_id}'
Remote Work
# remote host에서 session 생성 또는 재접속 ssh server tmux new-session -As work
- detach: Ctrl+B 다음 D
- 새 window: Ctrl+B 다음 C
- 다음/이전 window: Ctrl+B 다음 N/P
- pane 좌우 분할: Ctrl+B 다음 %
- pane 위아래 분할: Ctrl+B 다음 "
- key 도움말: Ctrl+B 다음 ?
Configuration
- 기본 user config는
~/.tmux.conf다. - 최신 tmux는
$XDG_CONFIG_HOME/tmux/tmux.conf도 지원한다. - config 작성, option scope, key binding, reload와 검증은 tmux configuration을 참고한다.
Troubleshooting
no server running은 실행 중인 tmux server가 없다는 뜻이다. 새 session을 만들거나 socket option이 일치하는지 확인한다.- nested tmux에서 key가 바깥 session에 전달되면 prefix를 두 번 누르거나 각 server에 다른 prefix를 설정한다.
- 색상이나 full-screen application이 깨지면 바깥 terminal의
TERM과 tmux의default-terminal설정을 확인한다. - SSH 재접속 후 agent socket이 오래된 값이면 새 session에서 시작하거나 server environment의
SSH_AUTH_SOCK을 갱신한다. - version별 command와 option은
man 1 tmux와tmux list-commands로 확인한다.
Compatibility
- tmux는 Unix 계열 terminal 환경을 대상으로 한다.
- 최신 upstream release만 공식 지원되며 distribution package에는 오래된 version이 포함될 수 있다.
- 일부 option, format, key flag는 version에 따라 다르므로 automation에서
tmux -V를 먼저 확인한다. - 공식 Windows native 또는
winget설치 안내는 없다. Windows에서는 WSL, Linux VM 또는 remote Unix host를 사용한다.
Help
See Also
History
- codex:: 2026-07-27 Added installation, sessions, windows, panes, key bindings, examples, troubleshooting, and compatibility guidance.