# tmux / byobu

## Why we use tmux (or byobu)

Even though we are using [ssh-access](https://www.projectpanoptes.org/build/software/appendix/ssh-access "mention") to start and stop our POCS software, we want the software to continue running after we have disconnected and so we can't just run things directly in the terminal.&#x20;

Instead, we need to run them in a sort-of background terminal (technically it's called a terminal multiplexer).

Both `byobu` and `tmux` do exactly that. So the idea is that you ssh into your remote computer, then you start `byobu` (or `tmux`) if it's your first connection, otherwise you can "attach" to the existing session by typing `byobu a` (or `tmux a`).

As a bonus, we can also split our screen into multiple "windows" and "panes" and have a different shell in each of these. For example, you can keep the log files open in a lower pane and run the commands in an upper pane. See the images below for examples.

### What's the difference?

`byobu` is actually just a wrapper around `tmux`, which gives some better defaults and a nice-looking status prompt. `byobu` is available by default on ubuntu and many ubuntu tutorials refer to it.

`tmux` is basically the same thing but a little more "raw".  On the other hand, `tmux` tends to be more widely available on non-ubuntu systems.

The big difference comes down to the "command key", with `byobu` using `Ctrl-a` and `tmux` using `Ctrl-b`. :person\_shrugging:

## Attach to byobu session

When observing, you can use byobu ([byobu.org](https://byobu.org/)) to split your terminal into multiple smaller panels with different processes running in each. That way, you can view the running POCS and log files all at once, which is especially convenient when logging in remotely. It also allows other people on your team to join the same byobu session and see how the unit is doing.

![](https://522439161-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpocs-user-guide%2F-MDuokRQRsq9CoS-8DwH%2F-MDuoyJaeUaVZqghGkcV%2F2.png?generation=1596567319011731\&alt=media)

By default, byobu should already be installed on Ubuntu. To attach, enter byobu in a new terminal window on the NUC. Then, you can jump between panels by pressing `CTRL-a`, letting go, then pressing an arrow key `↑ ↓ → ←` in the direction you want to move. More commands (ie. splitting screens, resizing screens, creating windows etc) are listed below.

#### Byobu cheat sheet

{% hint style="warning" %}
The commands are the same for `tmux` but instead of `Ctrl-a` it's `Ctrl-b`.
{% endhint %}

**`CTRL-a`** then **`?`** - help

**`CTRL-a`** then **`\`** - kill byobu (& all running processes)

**`CTRL-a`** then **`CTRL-d`** - detach without kill (or just close the terminal window)

**Windows management**

**`CTRL-a`** then **`c`** - create new window

**`CTRL-a`** then **`k`** - kill current window

**`CTRL-a`** then **`p`** - goto previous window

**`CTRL-a`** then **`n`** - goto next window

**`CTRL-a`** then **`[window number]`** - goto to a specific window (see bottom bar of terminal for all window numbers)

**Panels management**

**`CTRL-a`** then **`%`** - split current panel vertically

**`CTRL-a`** then **`|`** - split current panel horizontally

**`CTRL-a`** then **`TAB`** - next panel

**`CTRL-a`** then **`↑`**, - switch panels (with arrow keys)

**`CTRL-a`** then **`↓`**,

**`CTRL-a`** then **`→`**,

**`CTRL-a`** then **`←`**

Hold **`CTRL-a`** and press **`↑`**, - resize panels vertically

Hold **`CTRL-a`** and press **`↓`**

Hold **`CTRL-a`** and press **`←`**, - resize panels horizontally

Hold **`CTRL-a`** and press **`→`**

**Scroll up page buffer**

**`CTRL-a`**&#x74;hen **\[** - scroll with **`↑`** **`↓`** arrows, then press **`Enter`** to exit

{% hint style="info" %}
If you’re on a team, try to make your terminal as large as possible (<img src="https://522439161-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpocs-user-guide%2F-MDuokRQRsq9CoS-8DwH%2F-MDuoyJbTEjqEF8RViMX%2F3.png?generation=1596567318833665&#x26;alt=media" alt="" data-size="line"><img src="https://522439161-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpocs-user-guide%2F-MDuokRQRsq9CoS-8DwH%2F-MDuoyJcEd32IHY_SDvh%2F4.png?generation=1596567318843884&#x26;alt=media" alt="" data-size="line"><img src="https://522439161-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpocs-user-guide%2F-MDuokRQRsq9CoS-8DwH%2F-MDuoyJdXlgHae4wNAPs%2F5.png?generation=1596567318848976&#x26;alt=media" alt="" data-size="line">) when using byobu, since you might restrict the size that the session appears to anyone else attached. See pic below.
{% endhint %}

<figure><img src="https://522439161-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpocs-user-guide%2F-MDuokRQRsq9CoS-8DwH%2F-MDuoyJeNk83zfLZ-FO9%2F6.png?generation=1596567318891912&#x26;alt=media" alt=""><figcaption><p>If more than one person is connected the screen will resize to the smallest display.</p></figcaption></figure>
