Skip to content

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:
tmux

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
CTRL-B ”

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
CTRL-B %

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

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

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

Selection_070.png

For re-attaching just type:
tmux attach

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

Let’s work together

Ready to operate at
the next level?

Tell us about your challenge. We’ll bring the depth, the expertise, and the Swiss precision.

Open source Team

Open source Team

Posts published under the Open source Team account are collective contributions by the dbi services open infrastructure consultants. The practice covers open-source databases and platforms, PostgreSQL first of all, along with MySQL, MariaDB, and Linux, from architecture, replication, and high availability to performance tuning and operations under service level agreements, and contributes actively to the PostgreSQL community.View Author posts

721 posts since September 2011

Most read in Database

The Database posts our readers open most: the all-time favourites, and what is trending right now.

Leave a Comment

Your email address will not be published. Required fields are marked *