Improve your remote SSH sessions with Byobu
Transcription
Improve your remote SSH sessions with Byobu
Tutorial Byobu Improve your remote SSH sessions We can manually assign which two or more windows to enable here Here you can see a screen that has been split into two vertically. We can also have more splits if we like At the bottom of the window is a list of open windows and the status of the machine you are using Improve your remote SSH sessions with Byobu Byobu is an enhancement for GNU Screen that features lots of powerful shortcuts and is incredibly easy to use. Here’s how to improve your remote SSH experience the easy way… 44 www.linuxuser.co.uk 044-047_LUD_95 PK.indd 44 Byobu is a Japanese term for decorative, multi-panel screens that serve as folding room dividers. Byobu is also the name of a project that enhances GNU Screen. If you have used or regularly use the GNU Screen utility, you might have an idea about just how much it can help enhance your remote SSH sessions. It gives you a lot more power and flexibility than the regular Terminal window would otherwise. The issue with Screen, though, is that it can be a bit awkward to get to grips with – the polar opposite of Byobu… Advisor Sukrit Dhandhania has spent several years working professionally, implementing several open source tools for companies. During this time he has evaluated, set up and maintained various open source tools for these firms Resources Byobu is an enhancement package for the GNU Screen application https://launchpad. net/byobu 01 Install Byobu on Meerkat Getting Byobu is pretty simple, at least on Ubuntu Linux. If you are using the latest release of Ubuntu, which is Ubuntu 10.10 Maverick Meerkat or better, you should be able to find Byobu in the apt-get repositories. Launch the Synaptic Package Manager, search for ‘byobu’ and install the package (Fig 1). 02 Install on others If you are using another distribution of Linux, check in its application repository to see if there is a binary. If you are using another version of Ubuntu Linux and you can’t find the app in the apt-get repositories, you can use the following © Imagine Publishing Ltd No unauthorised copying or distribution 3/12/10 18:50:21 Improve your remote SSH sessions with Byobu Use Byobu to enhance GNU Screen to give you more power and flexibility TUTORIal configuration. Hit F9 to load the tool’s configuration module. This configuration interface works as a textual menu. You can navigate it by using the up and down arrows. Hit the Tab button to move from one section to another. Use the spacebar to select or deselect an item. If you need help at any time, hit Enter on the ‘Help -- Quick Start Guide’ option. Fig 1 Install Byobu on Meerkat The Byobu installation process on Ubuntu Meerkat is very simple indeed method to install Byobu. Note: Replace the term ‘UBUNTU_VERSION’ with the name of your release, such as jaunty, intrepid or hardy. # sudo bash -c “echo ‘deb http:// ppa.launchpad.net/byobu/ppa/ubuntu UBUNTU_VERSION main’ >> /etc/apt/ sources.list” # sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F430BBA5 03 Test Byobu Execute the command ‘# byobu’ from the Terminal window. You should see the window change and look something like the screenshot below. However, if you received an error stating something like ‘Error: Can’t open slave tty /dev/ pts/1 -- Permission denied’, you will need to fix some permissions. Execute the command ‘# sudo chmod a+rw /dev/pts/1’. Change the 1 to the number from the error message. n What Byobu looks like at first launch, with its default settings 04 The Byobu Interface You will note that there is a colourful strip of information being displayed at the bottom of the Terminal window. This is part of the enhancements that Byobu bring to the Terminal. By default it displays some basic information like the machine’s name and IP address, along with a few statistics about the state of the machine, such as the amount of RAM and CPU being used. Here’s a more complete list of things that Byobu can display in the strip at the bottom of the Terminal screen. 1. Screen windows list 2. Battery status 3. CPU count 4. CPU frequencies 5. Current date/time 6. Disk space 7. EC2 cost 8. Fan speed 9. Hostname 10. IP address 11. Load average 12. Mail count 13. Memory available/used 14. Network transfer speeds 15. Temperatures 1. Processes running (count) 2. Users logged-in (count) 3. Wi-Fi quality 4. Updates available 05 Customise Byobu n The Byobu application menu 06 Change the look and feel The first set of customisations we’ll look at will enhance the look and feel of the Terminal. Byobu gives you a couple of options on this front. You can change the background and foreground colours being used in the Terminal. Enter the two sections for picking colours, choose the colour you like for each option and then hit the Apply option. If you don’t like it, you can always return to the menu and change the colour. n Pick a colour to customise the look of your Terminal windows 07 Status notifications We’ve found the status notification bar at the bottom of the screen to be immensely useful. The fourth option in the Byobu config menu is to configure what goes into this status notification bar. Hit Enter on this menu option to start. Now pick the info you want displayed constantly on With so many more options to view information, it is easy to customise Byobu’s © Imagine Publishing Ltd No unauthorised copying or distribution 044-047_LUD_95 PK.indd 45 45 www.linuxuser.co.uk 3/12/10 18:50:37 Tutorial Byobu Improve your remote SSH sessions Fig 2 The new window You can see a list of windows in the status bar your screen. Note that you do not want to go overboard with your selection as it could be quite distracting. Choose the Apply option when done. presented with some options. You can pick which shell you want to use for the window, you can give it a name, you can choose from some presets, and you can add it to your list of default windows. Hit Apply to create a new window. Moving between windows 09 The new window the status bar 08 New window options If you are familiar with using GNU Screen, you might be aware of the powerful virtual Terminal interface that it provides you with. You can access this option in Byobu by selecting the ‘Create new windows’ option. Here you are Another very interesting feature makes it possible to split the screen into regions – either vertically or horizontally 46 www.linuxuser.co.uk 044-047_LUD_95 PK.indd 46 different operations going on in parallel 11 n Launch a new window through the menu n Select the notifications you want to see in n A horizontally split window with two What happens when you hit Apply in the previous step is that you are immediately taken to the window that you just created. You can use the F3 key to move around between windows that you have created. You should be able to see a list of the windows in the byobu status notification bar as you create them (Fig 2). 10 Split the screen Another very interesting feature makes it possible to split the screen into regions. With ‘Ctrl-a S’ you can create a new horizontal zone. This area will not contain anything at first, but you can move the focus there with ‘Ctrl-a <tab>’ and then activate a window in this region with a command to switch windows as ‘Ctrl-a N’. If you prefer a vertical division of the windows, you can use ‘Ctrl-a |’, which will do exactly the same thing but by dividing the screen into two regions with a vertical dividing line. As you get comfortable with working with multiple virtual windows, you will start finding a need to be able to quickly switch between windows, to toggle between them, and even to be able to jump straight to a particular window. Byobu has all these options ready for you. Use ‘Ctrl-a n’ and ‘Ctrla p’ to switch to the next or previous window in the list, by number, and ‘Ctrl-a #’, where # is a number from 0 to 9, to switch to the corresponding window. To get a full-screen list of windows, use the combination, ‘Ctrl-a ” ’; navigate this list with the arrow keys and pick a window to activate by pressing Enter when it is highlighted (Fig 3). 12 Name or rename a window You can name or rename a window with relative ease, even as you are using the window. Hit the key combination of ‘Ctrl-a A’. You will see a prompt where you can see the old name of the window. Remove it and set your new name there. Hit Save for it to get saved. n Rename a window to make it easier to keep track of it 13 Default windows In a previous step we looked at the process of creating a new window from the Fig 3 Moving between windows A list of open windows © Imagine Publishing Ltd No unauthorised copying or distribution 3/12/10 18:50:54 Improve your remote SSH sessions with Byobu Use Byobu to enhance GNU Screen to give you more power and flexibility TUTORIal h Move the cursor left by one character j Move the cursor down by one line k Move the cursor up by one line l Move the cursor right by one character 0 Move to the beginning of the current line $ Move to the end of the current line G Moves to the specified line (defaults to the end of the buffer) / Search forward ? Search backward n Move to the next match, either forward or backward Byobu menu. There was an option there to add the window to the default list of windows. This is a list of windows that will get launched by default. You can view and manage this list by going to the ‘Manage default windows’ option in the menu. Here you can select the windows you want launched when you launch the Terminal. 16 Keyboard shortcuts n Manage the list of windows you want launched by default 14 Manual configuration If you would like a bit more control over the configuration of Byobu, you can access the configuration files from the hidden folder called .byobu under your home directory. Here you will find a number of configuration files such as the status file where you can easily configure your preferred settings manually (Fig 4). Fig 4 Manual configuration The manual configuration is a good option for advanced users, offering extra control 15 Moving around If you are familiar with the Vim or Vi text editors, you will find the navigation shortcuts of Byobu quite useful as they are pretty much the same. Here is a list of a few of the most useful movement keyboard shortcuts… Here are some useful keyboard shortcuts that you should familiarise yourself with. Tools like Screen and Byobu add a great deal of efficiency to your workflow. However, if you are dependent on using the mouse for menus, things might slow down a bit. Once you are familiar with Screen/Byobu keyboard shortcuts, you will see a noticeable change in the speed and efficiency with which you go about working on the Terminal interface. F2 Create a new window F3 Move to previous window F4 Move to next window F5 Reload profile F6 Detach from this session F7 Enter copy/scrollback mode F8 Re-title a window F9 Configuration menu F12 Lock this Terminal 17 Launch Byobu by default If you want Byobu to be activated automatically every time you launch the Terminal window, you will need to make a change to the settings. Hit F9 after entering the Byobu interface. You will be presented with a menu. Choose the last option in the menu. Hit Enter to toggle the option whether to log into Byobu upon login or not. Then in the gnome-terminal application, go to Edit> ‘Profile preferences’ and select the ‘Title and Command’ tab. Check the ‘Run command as login shell’ option (Fig 5). In this article, we looked at a few of the options that the wonderful tool Byobu gives us. However, it is very difficult to cover all the useful options. Therefore we strongly urge you to spend some time reading the application’s man page. It will greatly help you enhance your workflow. Fig 5 Launch Byobu by default Set Byobu as your default Terminal interface © Imagine Publishing Ltd No unauthorised copying or distribution 044-047_LUD_95 PK.indd 47 47 www.linuxuser.co.uk 3/12/10 18:51:10