From the Canyon Edge -- :-Dustin

Sunday, December 14, 2008

The Ubuntu Server already includes a Window Manager?


The Ubuntu Server has always had a command-line only interface, and has never included a graphical desktop, such as Gnome, KDE, or XFCE. We differ quite a bit from other Linux distributions in this respect.

But did you know that the default Ubuntu Server installation, as of Intrepid Ibex, does include a window manager by default? Expand your mind a bit and check out the venerable GNU screen utility!

screen is simply an incredible program--dare I say that any good Linux/UNIX system administrator really must get to know screen. You can multiplex several tasks, send them to the background, and bring them to the foreground later, and customize task bars with all sorts of interesting information. I've never considered myself a screen expert, but I know enough to know that there's a lot I don't know :-)

The default configuration of screen in Ubuntu is quite functional, but it's lacking, um, pizazz... It's capable of a lot more.

The following is the result of several hallway conversations at last week's Ubuntu Developer Summit in Mountain View, California. Nick Barcet and I decided that the Ubuntu Server could, and should include some more useful profiles for screen, that take advantage of its more advanced features. Dave Walker helped with some early prototyping, adding some code that detects when updates are available and a reboot is required. We kicked around the idea a bit more with Kees Cook, Jamie Strandboge, and Steve Langasek.

So I created a new package this morning, screen-profiles. This package currently includes two screenrc profiles that I created, one for Ubuntu, and one for Debian. It also contains a binary, select-screen-profiles, which provides an interactive method for quickly switching among the available profiles on the system.

I have uploaded packages for Hardy, Intrepid, and Jaunty. To install, add my PPA to your /etc/apt/sources.list. And then:
$ sudo apt-get install screen-profiles
$ select-screen-profile

Here's a sample screen shot.


Notice that the first status bar across the bottom actually contains "tabs" of the open screen sessions. You can use ctrl-a-c to create a new tab, and ctrl-a-0 .. ctrl-a-4 to swtich among the available tabs. The highlighted tab is the currently active one, 1 source.

The second status bar I've reserved for system state information. Currently, this includes the current LSB release and version, Ubuntu 8.10. The blue @ indicates that a system restart is required (it's supposed to look like the Ubuntu restart icon). The red 28! indicates that there are 28 updates available. And, of course the system time follows. Note that an Ubuntu circle-of-friends logo is pretty much impossible with a standard character set, but hopefully the 3-colored \o/ logo approximates the "spirit" of Ubuntu ;-)

And for good measure, I tested this on a Debian and a Fedora system, each with their own logo approximations in the lower left.

Debian:

Fedora (on a black console, just to show that look too):

So I think I'm just scratching the surface of the possibilities of screen for the Ubuntu Server. I'm really interested your favorite ~/.screenrc profile! If you're doing something interesting or cool with your screen configuration, please post your ~/.screenrc (with a GPLv3 header) and screenshots in your blog, and add a URL here as a comment. I'm hoping to ship this package in the Ubuntu Jaunty Server with a number of interesting profiles.

If you're looking for more information on customizing these screenrc files and the various commands, take an hour and read the screen(1) manpage. It's a long one ;-)

:-Dustin

20 comments:

  1. Dustin, you rock :)

    I'm still trying to find a way for C-tab to switch between screens, which would be a lot more intuitive for many users than C-a N.

    What about having a couple tabs open by default, one of them providing some more detailed info about the running server?

    ReplyDelete
  2. I’d like to recommend you htop if you don’t know it yet :)

    Also, do you use mc? I’ve noticed that the newest version in Intrepid (and SUSE 11.0) differs from the previous one, they redefined a keyboard shortcut I had been using for years — and for no apparent reason they moved it to the next key and assigned something else to said shortcut (Alt-O, make the other panel contain the same dir as the active one; has become Alt-I instead and Alt-O opens the highlighted directory and moves the cursor down instead.)

    ReplyDelete
  3. This is absolutely enlightening. Though I've often thought of making a profile myself, when I'm logged into the server I usually have a higher-priority project that I'm supposed to be attending to!

    I'd love to see this expanded further using the "dialog" package. Screen's always been interesting to me, but the vast number of choices are overwhelming.

    * Choose between different profiles examples.
    * Modify basic layout: number of toolbars, position of them
    * Add/remove/configure widgets in the toolbars

    ReplyDelete
  4. Very nice!
    I'm using it/loving it.

    ReplyDelete
  5. (via Planet Ubuntu) Cool!

    My favourite bit of my .screenrc is:

    # Ctrl+PgUp and Ctrl+PgDn to change windows
    bindkey ^[[5;5~ prev
    bindkey ^[[6;5~ next

    ...which let me switch from using gnome-terminal tabs to windows in screen without having to relearn keyboard shortcuts.

    I still haven't learned to use screen's scrollback key combos, so I Googled up some configuration that makes the scrollback history available to gnome-terminal and others. There seem to be several ways to do this, but again it's something that has helped me transition.

    ReplyDelete
  6. Thanks for this - will definitely try it! I didn't realise it was possible to get the list of tabs across the bottom. I spend a lot of time in screen trying to remember which window I'm in.

    ReplyDelete
  7. I posted a follow up with a few additional quirks at http://nicolas.barcet.com/drupal/screen-by-default

    ReplyDelete
  8. Wow, this is really awesome! Keep thinking out of the box!

    ReplyDelete
  9. Using the package, screen takes a while to start. I am using the following in my .bashrc:

    if [ "$TERM" != "screen" ]; then
      screen -xRR
      logout
    fi

    When I open gnome-terminal, it takes up to 10 seconds for any output to appear. I figured out this was because /usr/share/screen-profiles/bin/updates-available was taking a long time to query the apt database.

    The screen manpage provides another way to do this:

    1. Change the line in /usr/share/screen-profiles/profiles/common from "backtick 101 3600 3600 ..." to "backtick 101 0 0 ...".

    2. Wrap the whole updates-available script in a "while [ 1 ]" loop, with a "sleep 3600" as the last command.

    This makes the initial prompt come up much faster...maybe the same can be done for the other scripts. There may be some resident memory, but then there is usually only one instance of screen running on a given machine.

    ReplyDelete
  10. Thanks Justin, that's great!

    I've posted a follow-up with some ideas on my blog : http://raphink.info/2008/12/follow-up-on-screen-profiles.html

    ReplyDelete
  11. Thanks for this great post! I had not been familiar with screen at all until I read your blog and you have opened up my eyes to a entirely new world of features. Cheers!

    ReplyDelete
  12. This is spectacular! It's going to take awhile to get accustomed to the CTRL-G, but I had no idea that screen could be customized so effectively. This needs to be made default!!

    ReplyDelete
  13. MORE COMMENTS!

    I use htop, in which F6 is bound to change the sort order of the display.

    This is trouble, because the latest screen-profiles uses F6 for 'kill'.

    I tried to unbind by issuing "bindkey -k k6" in my local ~/.screenrc, but that seems to disable the Ctrl+PgUp and Ctrl+PgDn shortcuts :( Can anyone else duplicate this?

    Also: a wealth of ideas here: http://dotfiles.org/.screenrc

    ReplyDelete
  14. Hey Dustin. amazing package!
    works like a charm on my Intrepid machine but I connect to debian machines (etch and lenny) all day long and miss screen-profiles.
    What's the easiest way to install screen-profiles on debian? Coz i cannot find the .deb files.

    Greetings

    ReplyDelete
  15. Toni-

    Hi, thanks for the compliments.

    I have provided a Debian profile.

    I suspect that the package would install on a Debian system, though I haven't tested it myself.

    I am not a Debian developer, so I cannot add it to their archive. However, I would be quite happy to work with Debian, if they would like this in their distribution as well. If there's a volunteer Debian Developer out there who would like to run this on their side, please email me.

    Cheers,
    :-Dustin

    ReplyDelete
  16. Hey. thanks for the fast reply. The thing is: http://us.archive.ubuntu.com/ubuntu/pool/universe/s/screen-profiles/ is empty.. no debs there to try

    ReplyDelete
  17. Toni-

    It has been promoted from Universe to Main!

    http://us.archive.ubuntu.com/ubuntu/pool/main/s/screen-profiles/

    I'll try to update the urls pointing to this...

    :-Dustin

    ReplyDelete
  18. Can this be used on other distro's? I run RHEL 5 at work.

    ReplyDelete
  19. Hi!
    I'm happy to use your work on my new jaunty server, but my hardy ones would like it too... Your PPA has the package marked as deleted or superseded though, and it's not available in the hardy repos. What could I do to install it anyway?
    Thanks for your work!!

    ReplyDelete
  20. So, it seems I found the answer to my question: I need https://launchpad.net/~byobu/+archive/ppa, seen your blog post "byobu 2.0 released -- the project formerly known a..."
    I'll give it a try right now. Bye!

    ReplyDelete

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin

Printfriendly