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.
99 readers like this
99 readers like this

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 screenshot

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.

What to read next
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.

2 Comments

Hi, there is terminator which is graphical interface for tmux. Those programs has the same capabilities as byobu, what got me hooked on tmux was ability to run the same command on multiple panes with setw synchronize-panes on. From what I've just read it has more intuitive shortcuts out of the box.
Great article :).

I think we already have tmux and screen for the same things. I use tmux for my daily jobs and I am happy with it
Why do we keep reinvent the wheel here
We should spend time and resource for things really and really new
My two cents

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.