dcsimg

Introduction to tmux: A GNU Screen Alternative

By Joe Brockmeier (Send Email)
Posted Mar 14, 2011


GNU Screen is one of the most useful utilities for any admin, but what if Screen isn't your cup of tea? For the longest time, GNU Screen was the only game in town -- but the up-and-coming tmux is worth checking out.

Need to run multiple sessions in the same terminal but aren't fond of screen? Consider tmux, open source software that offers Emacs and vi-style keybindings.

What's tmux? Like Screen, it's a "terminal multiplexer," which is a fancy way of saying you can run multiple sessions in the same terminal (and then some). Like Screen, tmux does much more than just let you manage "windows" (or, you know, screens if you prefer) running pseudo terminals.

How does tmux differ from Screen? Aside from licensing (GNU Screen is GPL'ed, tmux is BSD licensed), which is a big hairball that I won't get into, tmux offers a few features that Screen does not. First and foremost for me? You have the option of Emacs or vi-style keybindings with tmux. OK, that's a major feature for Vim-addicts like me, but what about the rest of the world?

Another big feature in tmux is search. If you have two or 10 or 20 windows running in tmux, you can quickly find the one you're looking for by running Ctrl-b f and then the search string that you're looking for. For example, I could return to this window (editing this piece in Vim) by searching for "tmux."

And you've probably noticed that the prefix for sending a command to tmux is a bit different -- Ctrl-b instead of Ctrl-a.

By default, tmux displays a status line with the names of the windows that are open. You can modify Screen do this, but it's not the default out of the box. (The Ubuntu-led byobu project does this, and a lot more to prettify and make Screen easier to use). The window names automatically update depending on the command being run. For example, when I run Vim in a window, the title becomes "vim." When I run top, then it becomes "top," and so on. A minor, but handy, feature.

Another nifty feature with tmux? Support for preset pane layouts. What's a pane? Panes are divisions of the window, each running their own pseudo terminal. Using tmux, like GNU Screen, you can divide a window into two or more panes each running their own terminals. Unlike GNU Screen, you can configure presets -- handy if you have a set working pattern that you like to preserve between sessions. (Like GNU Screen, you can detatch a session and return to it later -- but you must reboot systems sometimes!)

What are the drawbacks to tmux? Screen has been around longer and supports more platforms. If you're on HP-UX, you're stuck with Screen. If you need telnet support built-in, or serial support you're stuck with Screen.

If you happen to be running OpenBSD, then tmux should be installed by default. If you're on Linux, most major distros should have it packaged already (I found it on Ubuntu, openSUSE, and by default on Mac OS X, and it should compile on just about any *nix type system). I've been using tmux only for a few weeks, so I haven't made up my mind whether I'd like to switch permanently. But I think it's a good thing that there's "more than one way to do it," and I like some of tmux's features. Like screen, tmux takes some getting used to — the basics are easy, but tmux has a lot of power if you're willing to spend the time getting to know it. Next week we'll look at tmux usage and how to bend it to your will.

Joe 'Zonker' Brockmeier is a freelance writer and editor with more than 10 years covering IT. Formerly the openSUSE Community Manager for Novell, Brockmeier has written for Linux Magazine, Sys Admin, Linux Pro Magazine, IBM developerWorks, Linux.com, CIO.com, Linux Weekly News, ZDNet, and many other publications. You can reach Zonker at jzb@zonker.net and follow him on Twitter.

Follow ServerWatch on Twitter

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.