使用 tmux 的最少指令

tmux 是一個終端多工器。當我們需要在後台在遠端伺服器上運行長時間運行的任務並稍後檢查結果時,它非常有用,而不需要保持持續的 ssh 連線並擔心網路故障導致任務意外退出。以下是滿足大多數用例的最少指令清單。

列出現有會話

# list existing sessions
$ tmux ls

建立新會話

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

分離現有會話(即置於後台)

# 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 to an existing session
$ tmux attach -t <session-name>

終止現有會話

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

linux