使用 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>