---
# System prepended metadata

title: tmux tutorial
tags: [tmux]

---

# tmux tutorial
###### tags: `tmux`

# Install tmux
```bash=
sudo apt-get install tmux
```


# Windows

建立新的session，
```bash=
tmux
```
或自行命名session name
```bash=
tmux new -s <session name>
```

### 在tmux中:
- Crtl-b c 建立一個新視窗
- Crtl-b p 上一個視窗
- Crtl-b n 下一個視窗
- Crtl-b [ 向上滾動，q退出
- Crtl-b d 離開session
- Ctrl-b x 關閉當前視窗

# Reconnect session

查看tmux
```bash=
tmux ls
```

![](https://i.imgur.com/25XZnHC.png)

選擇現有tmux的session
```bash=
tmux attach -t <session name> 
```

# Delete session
```bash=
tmux kill-session -t <session name>
```

# Rename session
```bash=
tmux rename-session -t 0 <new_session_name>
```

# Detach session and attach (when the windows is too small)
```bash=
tmux attach -d
```



