Get the highlights in your inbox every week.
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.
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.
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:
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.