2010-07-19

Three-way mini shootout between GNU screen, tmux and dtach+dvtm

When it comes to terminal managers in Linux, it usually boils down to three choices: screen, tmux or the dtach+dvtm duo. Proponents of each often vigorously tout their solution as the best. So let's see how they compare.

The Contenders

  • GNU screen is the oldest and perhaps most widely used of the terminal managers in this comparison. It has been around since the 1980s and made thousands if not millons of users' lives easier since then.
  • tmux is a relative newcomer, the first release dating to late 2007. It was developed specifically with the goal of overcoming limitations in the implementation of screen.
  • dvtm is best described as tiling window manager for the console. First released in late 2007 too, it lacks the disconnection/reattachment feature of the other two solutions, so it will unleash its full power only in combination with dtach which does exactly that. (Using screen/tmux with dvtm is also possible.) dtach was released in 2004.

The Parcours

The contenders will have to show how they perform in the aspects that matter to the modern geek. This includes mind share, adherence to Unix philosophy, features, efficient use of resources and ease of use.

Mind share

GNU screen has been around longest, so has had more time to capture users. Measuring popularity using Google is a bit difficult, as searching for "GNU screen" (with the quotes) will probably under-report while searching for "screen" will over-report actual numbers. A Google Trends analysis omitting the quotes sees screen in front, with tmux a distant second. This more or less matches the Debian Popularity Contest, which currently clocks screen at position #756, tmux at #6159 and dtach/dvtm at #6242 and #8604 respectively.
Winner: screen

Unix Philosophy

The Unix tools were developed with several precepts in mind, an important one being "Make each program do (exactly) one thing well". In this tradition, dvtm tried not to include everything but the kitchen sink, but instead leaves the disconnection/reattachment function to dtach, and displays auxiliary data such as the status bar and clock via named pipes.
screen and tmux on the other hand integrate all functions in one large binary.
Winner: dtach+dvtm

Features

Besides the ability to open several shells in one terminal/console, all contenders have a scrollback buffer, can do copy and paste and display status information. Both dvtm and tmux have mouse support and are able to align multiple shells nicely, not like in screen's limited fashion. Its client/server model allows tmux however to provide one notable feature, sending/sharing sessions between different connected clients. [Update: A commenter alerts me to the fact that screen can do this too. Still, tmux has more features.]
Winner: tmux

Efficient use of resources

In the time that screen has been around, it was able to accumulate a lot of legacy code, which results in a download size of 821 KiB. tmux is noticeably smaller, only 237 KiB. But this is still huge in comparison to dtach and dvtm, whose combined download size is only 81 KiB. This is probably due to their adherence to Unix principles, which helps to keep the bloat at bay.
But not only the download is smaller, the memory usage of a dtach+dvtm session is significantly below that of the others, too.
Winner: dtach+dvtm

Ease of use

The best way to start screen or tmux is just running the binary. You will be immediately in an environment where you can use all the features. dtach and dvtm have to be started together, and the user himself has to manage the dtach sessions manually.
Winner: Tie between screen and tmux

Conclusion

All contenders have been able to win two of the comparisons. If you are already used to screen and don't need the extra features of tmux, then you can stay with screen.
If you prefer an elegant and Unix-like approach, dtach+dvtm are what you want.
If you however want many features and a solution that Just Works™, then tmux may be for you.

7 comments:

Anonymous said...

Somehow I don't remember even hearing/reading about tmux or dtach+dvtm, though I've been using screen for longer that they've existed. So big thanks for writing about them, I'll have to try them out!

Anonymous said...

I think you need to reinvestigate screen. It also has a client/server architecture and also allows sharing sessions between clients. At its simplest, invoking with screen -x does that. But they can be passworded and ACLed as well.

Anonymous said...

Xdefaults please :)

Anonymous said...

this is a somewhat biased "comparison"
screen also supports the mouse, can do window management besides terminal multiplexing (including vertical splits), has really great flow control, is configurable _and_ scriptable and if you take into account the ratio between features and resources it actually consumes very little doing so (yes, even compared with dvtm)
it should also be mentioned that gnu screen's documentation is very complete and organized which is always a boon in cli apps that can provide little in the way of intuitiveness and feedback and that screen unlike it's contenders will degrade properly according to available features of the client terminal (so the fancy colorful htop in my company's server will provide meaningful info even in the half backed term emulator on my cellphone without being reconfigured specifically for it)

[this should be enough to show the gap between them and screen, if not read the doc or realize how biased you are ;)]

all the best

Unknown said...

Thanks for your insights. Yes I am biased, I maintain dvtm in Gentoo :)

Concerning mouse support, I could not figure out how to make mouse clicks activate regions (which works in dvtm and tmux). But maybe it is only my inability.

Regarding region splits, if you want to achieve something akin to dvtm offers, then you have to program it into screen and it won't even persist across disconnects (though I understand that this is going to be fixed in the next release).

You are correct that documentation and extensibility were omitted in my comparison. They didn't seem to matter to me (and by extension, to any proper geek ;) ) when I wrote it, but this may be worth reconsidering.

Anonymous said...

Nice review, but screen has way more features, it is just that you are not familiar with them =)

for example you can share a conection with screen and you have several options. For example, a guest can ro (just watch) or enter commands, depending on how you configure the shared session.

You can also text guests with the screen feature "wall".

Screen does not tile sessions, but you can have multiple windows and navigate through them.

http://www.pixelbeat.org/docs/screen/

http://www.linux.com/archive/feed/56443

http://www.linuxjournal.com/article/6340

http://www.rackaid.com/resources/linux-screen-tutorial-and-how-to/

Anyways, I am off to give tmux and dvtm a spin.

Ferk said...

Are you sure about the combination dtach + dvtm being more lightweight? How did you test it? does it escalate?

I've been trying it out a bit and it seems that dtach opens one process for each session running in the background, while tmux/screen only open one server process.

I was wanting to make my terminals open a dtach session directly, but this would result in 2 extra processes for each additional terminal. Is this still more efficient than using tmux and having one central server and only 1 process per terminal?