Infrastructure at your Service

Daniel Westermann

tmux – an alternative to screen

You may already use screen for multiplexing a terminal. This is especially useful when you want to start long running processes on a server and do not want to loose the connection because of a ssh connection timeout, firewall settings or other reasons. With screen the session keeps running even if you got disconnected somehow and you may re-attach to the screen session at any point later.

In this post I want to make you aware of another tool that does the same thing. It is called tmux and available for the most Linux/Unix platforms. Installation is straight forward and easy:

For debian based distributions:
apt-get install tmux

For redhat based distributions:
yum install tmux

Imagine you have an oracle database running on a server and you want to perform several tasks without the risk of loosing the connection. With tmux this becomes very easy:
Open a new tmux session:

You will be immediately connected to it. In this session do whatever you want, e.g. tailing the oracle alert.log: Selection_066.pngSelection_067.png
In another session you now want to do a restart of the database. In tmux you can horizontally split the screen by hitting

on the keyboard. Now you can do the restart of the database and watch the alert.log in the same session: Selection_068.png
Lets say you now want another screen for running top. No problem: Hitting

will split the screen vertically and you can now run top:

You can add as many screens as you want. Cycling through the screens is done by

and one of the up/down/left/right arrow keyboard keys. Detaching from the screen is done by


For re-attaching just type:
tmux attach

… and everything will be back.
The man page for tmux is here.

Daniel Westermann
Daniel Westermann

Principal Consultant & Technology Leader Open Infrastructure