DevOps

Using Byobu and Landscape to improve remote Ubuntu sessions

SSHing into remote servers can be an awkward experience, but it doesn't have to be. You can turn your ssh console into a terminal-style window manager with Byobu, and get more system information via landscape.

"Byobu is a Japanese term for decorative, multi-panel screens that serve as folding room dividers. As an open source project, Byobu is an elegant enhancement of the otherwise functional, plain, practical GNU Screen."

https://wiki.ubuntu.com/MeetingLogs/openweekKarmic/Byobu

SSH into your server and install the two packages:

sudo apt-get install byobu landscape-common update-motd

Next, run byobu-config:

 

byobu-config example

You can change Byobu's colors if you'd like. I like the "dark" theme.

The important setting to change is the last one: " Byobu currently does not launch at login". Select that and press return. Now you can go back to the menu and exit byobu-config (tab to the exit choice and hit return).

Now log out and log back in again. You'll now access Byobu automatically.

 

Byobu as your session manager

The new MOTD (that's "Message of the Day", which is the text that is displayed when you login) has system information, thanks to landscape-common. This will let you know if your almost out of memory or disk space, or if you're under heavy load.

Now let's look at the information Byobu provides. The bottom row of Byobu contains, from left to right, your Distribution logo and name, uptime, load, cpu frequencies, ram amount and usage, and the date.

The upper row are your windows. Press F2 to create a new window. Along the bottom of the screen you'll now see two entries in the top row of the footer. Press F3 to move to the previous window and F4 to move to the next window.

Press F8 , then give the window a name, like "echo". I like to name each tab with the task I'm doing, like "console", "mysql", and "top".

You can press F7 to enter copy/scrollback mode. Use the arrow and page-up/down keys to move around your session. Press the spacebar to start copying. Now move your cursor somewhere else. Then press space again to copy the selection. Byobu doesn't have a paste hotkey, so you have to use the screen hotkey, which is CTRL-a ] (thats CTRL-a , then let go of control and press ]).

You can press F12 to quickly lock your terminal, to grab a quick cup of coffee (or read this blog!).

Let's explore how to maintain a session. Issue the following command:

echo hi

That will print out "hi" on the screen. Now let's exit this session. Press the Byobu hotkey F6 to "Detach" from Byobu.

You'll notice you're still logged in, this is because Byobu is an application that runs on top of your session. So now you have to exit again to get back to your local machine.

Now SSH back into your machine. You'll notice that command is still on the screen! "Detaching" does not end your session, it just detaches you from it. That means you can log in, run a long running task, and then Detach and come back in the morning when your task is done.

For extended information on Byobu, check out its Ubuntu Man Page.

You've successfully subscribed to SmartLogic Blog
Great! Next, complete checkout for full access to SmartLogic Blog
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.