Sep 292010
 

ByobuIf you frequently use the terminals and the command line, I hope you know the command screen, otherwise get ready to see something that will help you immensely.

Screen ?

(from the man page)

Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells). Each virtual terminal provides the functions of a DEC VT100 terminal and, in addition, several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO 2022 standards (e.g. insert/delete line and support for multiple character sets). There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows moving text regions between windows.




When screen is called, it creates a single window with a shell in it (or the specified command) and then gets out of your way so that you can use the program as you normally would. Then, at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill existing windows, view a list of windows, turn output logging on and off, copy-and-paste text between windows, view the scrollback history, switch between windows in whatever manner you wish, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the user’s terminal. When a program terminates, screen (per default) kills the window that contained it. If this window was in the foreground, the display switches to the previous window; if none are left, screen exits.

Installation

Screen is available in many distributions, in Ubuntu is included in the base installation.

How to use Screen

Start screen just by typing screen at your favorite command shell prompt. You’ll probably be greeted by a welcome message. Dismiss this and you’ll have with an empty terminal containing a shell prompt, which is pretty much what you had before you started screen. What happened?

Every program running under screen runs in a window, and every window is identified by a unique number. Screen made a new window, numbered it 0, and started a command shell inside it. Type something in your new window so you’ll be able to recognize it when you switch to it later.

Now make another window; this will be window 1. To do this, type C-a c; that is, type Ctrl-a and then type c (mnemonic: create window).

Switch from a windows to the other

  1. Use C-a n and C-a p to switch to the next or previous window in the list, by number.
  2. Use C-a N, where N is a number from 0 to 9, to switch to the corresponding window.
  3. Use C-a ” to get a full-screen list of windows. You can navigate this list with the arrow keys, and pick a window to activate by pressing Enter when it’s highlighted.
  4. Use C-a ‘ to have a prompt  “switch to window” type the number of the window you want to switch on.

Name a window

use C-a A to give a name to current window otherwise you’ll have all windows with the same name (in my case it was “shell”)

Close a windows

Exiting the last program in a window will cause the window to disappear. You can also kill misbehaving programs with C-a K.

Detaching and reattaching

You can detach from a session by pressing C-a d. You can also detach just by closing the terminal emulator that contains the session. However, keep in mind that neither of these actually end your session. All they do is unbind your session from the current terminal. All of the programs you started running within screen are still running.

After the detach now start up a new terminal emulator, and type screen -r (the R, obviously, stands for “reattach”). You’ll be right back where you were when you detached.

One  good use for the detach and reattach is as a console-mode “remote desktop” feature. You can detach from a screen session at work, shell into the machine from home, and reattach.

Split screen

Another very interesting use of the screen is what makes it possible to split the screen into regions.

With C-a S (split) will create a new horizontal zone. This area initially will not contain anything, but you can move the focus there with C-a <tab> and then activate a window  in this region with a command to switch windows as C-a N.

I make use of this option to have in the upper half of the screen a tail -f of a log file and at the bottom i give commands that interact with that particular demon or process.

If you prefer a vertical division of the windows you can use C-a |, which will do exactly the same thing but by dividing the screen into two regions with a vertical dividing line.

For an online help check C-a ?

Check also http://www.kuro5hin.org/story/2004/3/9/16838/14935 a 2004 tutorial, but still good.

ByobuByobu

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. Byobu includes an enhanced profile and configuration utilities for the GNU screen window manager, such as toggle-able system status notifications.

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. You could have different info, like total number of processes or network statistics, these info are highly configurable.

Default F keys:

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.
F3 to move to the previous window
F4 to move to the next window.
F6 to detach from window.
F7 to enter copy/scrollback mode
F8 give the window a name, like “top”.
F9 enter in Byobu options.
byobu-config

Conclusion
If you use terminal on your desktop or on your server i’m sure you have understood the potentials of this small software. You can create remote job, detach, ask someone else to reconnect and perhaps later in the day reconnect your self, and this is just a small example.

Popular Posts:

Flattr this!

  9 Responses to “Screen and Byobu”

  1. I love screen, I’ve been using it for about two years now, and it’s especially useful for when I log in to my server, being able to detach and re-attach a session is a life saver.

  2. Yeah… Screen lovers…. this shyt rox man.. love it

  3. […] customizable. A screencast can be found here. After reading some descriptions of byobu here and here, I re-discovered screen’s ability to split screens. I’ll probably begin to use this […]

  4. You should also check out tmux. It’s a little different, but it’s gaining quite a bit of ground.

  5. […] Howto, Pills, Review Add commentsSep 152011 In a former article i’ve show how to use Screen and Byobu, in short Screen is a full-screen window manager that multiplexes a physical terminal between […]

  6. BYOBU is nice, but when I click on the “Help” line it sends an infinite number of screens that block out everything else (ie it takes control of the session) and it can not be paused or deleted. I have to do a power purge to free the system. How does that “help”?

  7. Finally! Someone who can explain for dummies how screen works! GOD BLESS YOU A LOT!!!!

  8. Ctrl+a+] not working in byobu ubuntu 12.04 13.04 >>>>how to paste text in terminal ?

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*