How to use byobu to multiplex SSH sessions | Opensource.com

How to use byobu to multiplex SSH sessions

Byobu allows you to maintain multiple terminal windows, connect via SSH, disconnect, reconnect, and share access, all while keeping the session alive.

Person drinking a hat drink at the computer
Image credits : 
x

Subscribe now

Get the highlights in your inbox every week.

Byobu is a text-based window manager and terminal multiplexer. It's similar to GNU Screen but more modern and more intuitive. It also works on most Linux, BSD, and Mac distributions.

Byobu allows you to maintain multiple terminal windows, connect via SSH (secure shell), disconnect, reconnect, and even let other people access it, all while keeping the session alive.

For example, if you are SSH'd into a Raspberry Pi or server and run (for example) sudo apt update && sudo apt upgrade—and lose your internet connection while it is running, your command will be lost to the void. However, if you start a byobu session first, it will continue running and, when you reconnect, you will find it's been running happily without your eyes on it.

the byobu logo
The byobu logo is a fun play on screens.

Byobu is named for a Japanese term for decorative, multi-panel screens that serve as folding room dividers, which I think is quite fitting.

To install byobu on Debian/Raspbian/Ubuntu:

sudo apt install byobu

Then enable it:

byobu-enable

Now drop out of your SSH session and log back in—you'll land in a byobu session. Run a command like sudo apt update and close the window (or enter the escape sequence (Enter+~+.) and log back in. You'll see the update running just as you left it.

There are a lot of features I don't use regularly or at all. The most common ones I use are:

  • F2 – New window
  • F3/F4 – Navigate between windows
  • Ctrl+F2 – Split pane vertically
  • Shift+F2 – Split pane horizontally
  • Shift+Left arrow/Shift+Right arrow – Navigate between splits
  • Shift+F11 – Zoom in (or out) on a split

You can learn more by watching this video:

How we're using byobu

Byobu has been great for the maintenance of piwheels, the convenient, pre-compiled Python packages for Raspberry Pi. We have a horizontal split showing the piwheels monitor in the top half and the syslog entries scrolled in real time on the bottom half. Then, if we want to do something else, we switch to another window. It's particularly handy when we're investigating something collaboratively, as I can see what my colleague Dave types (and correct his typos) while we chat in IRC.

I have byobu enabled on my home and work servers, so when I log into either machine, everything is as I left it—multiple jobs running, a window left in a particular directory, running a process as another user, that kind of thing.

Byobu is handy for development on Raspberry Pis, too. You can launch it on the desktop, run a command, then SSH in and attach yourself to the session where that command is running. Just note that enabling byobu won't change what the terminal launcher does. Just run byobu to launch it.


This article originally appeared on Ben Nuttall's Tooling blog and is reused with permission.

4 different color terminal windows with code

Streamline management of multiple machines with this handy tool.
2 windows with brown frames on a white exterior wall

With so many great open source options to choose from, it's worth taking the time to find one that works for you.
open source button on keyboard

Enter the black raspberry. Rubus occidentalis . It's an ominous name for an ominous fruit: the...

Topics

About the author

Ben Nuttall - Ben is a software engineer for BBC News Labs, and formerly Raspberry Pi's Community Manager. He's into Linux, Python and all things open source! Follow Ben on Twitter @ben_nuttall.