tmux / byobu
How to stay connected.
Last updated
How to stay connected.
Last updated
Even though we are using SSH Access 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.
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.
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
. 🤷
When observing, you can use byobu (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.
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.
The commands are the same for tmux
but instead of Ctrl-a
it's Ctrl-b
.
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
then [ - scroll with ↑
↓
arrows, then press Enter
to exit
If you’re on a team, try to make your terminal as large as possible () when using byobu, since you might restrict the size that the session appears to anyone else attached. See pic below.