How to improve your productivity in terminal environment with Tmux

The introduction of the mouse was a wonderful innovation in making computers more accessible to average people. But for programmers and sysadmins, moving our hands off the keyboard while working on a computer can be distracting.

As a sysadmin, I spend most of the time working in the terminal environment. Opening tabs and moving around windows through multiple terminals slows me down, and I just can't waste any second when something is going really wrong with my server.

Tmux is one of those tools that are essential for my daily work. With Tmux, I can create complex development environments, and have SSH connections side by side. I can create multiple windows, split panes, attach and detach sessions, etc. After mastering Tmux, you will throw out your mouse away ( just kidding don't do it :D ).

Tmux (short for "Terminal Multiplexer") lets us launch multiple terminals in a flexible layout on a single screen, so that we can work with them side by side. For example, on one pane we can edit some config files with Vim, while on the other we are using irssi to chat and on other pane, tailing some logs. Then open another window to update your system, and another to SSH to some servers. Navigating through them is just as easy as creating all these windows and panes. It is perfectly configurable and customizable so it can become an extension of your mind.

Install Tmux on Linux/OSX

You can install Tmux by compiling it from sources or via your operating system package manager. I recommend you to use a package manager. It's faster and easier than compiling.


# sudo brew install tmux
# sudo port install tmux


$ sudo apt-get install tmux

RHEL/CentOS/Fedora (RHEL/CentOS require EPEL repo):

$ sudo yum install tmux


$ sudo pacman -S tmux

Working with Different Sessions

The best way to use Tmux is working with sessions, so that you can organize your tasks and applications into different sessions the way you want. If you need to change a session, whatever runs inside the session won't stop or get killed. Let's see how it works.

Let's start a new session named "session", and run top command in it.

$ tmux new -s new session
$ top

then type CTRL-b d to detach from this session. To re-attach to it:

$ tmux attach-session -t session

And you will see top still running in the re-attached session.

Some commands to manage sessions:

$ tmux list-session
$ tmux new-session <session-name>
$ tmux attach-session -t <session-name>
$ tmux rename-session -t <session-name>
$ tmux choose-session -t <session-name>
$ tmux kill-session -t <session-name>

Working with Different Windows

Often you will need to run multiple commands and perform different tasks in a session. We can organize all of them on multiple windows in one session. A window can be seen as a tab on modern GUI terminal (such iTerm, or Konsole). After configuring our default environment in a session, we will be able to create as many windows as we would need within the same session. Windows, like our apps running in sessions, persist when we detach from the current session. Let's check out an example:

$ tmux new -s my_session

Press CTRL-b c

This will create a new window and move focus into it. Now you can start up another application in the new window. You can write down the name of your current window. In this case I was running top so that's the window's name.

To rename it just type:
CTRL-b ,

The status bar changes to let you rename the current window.

Once we create multiple windows in a session, we need a way to move through them. Windows are organized as an array, so every window has a number starting at 0. To jump quickly to other windows:

CTRL-b <window number>

If we have named our windows, we can look for them with:

CTRL-b f

and to list all windows:

CTRL-b w

and to move to a different window one by one:

CTRL-b n (go to the next window)
CTRL-b p (go to the previous window)

To leave a window, just type exit or:

CTRL-b &

You have to confirm if you want to kill off the window.

Splitting a Window into Panes

Sometimes you need to type in your editor and check a log at the same time, and having your editor and tail side by side is really useful. With Tmux, we can divide a window into multiple panes. So for example, we can create a dashboard to monitor our servers and a complex development environment with the editor, the compiler and debugger running together side by side.

Let's create another Tmux session to work with panes. First let's detach from any Tmux session in case we are in a running session.

CTRL-b d

Start a new session named "panes".

$ tmux new -s panes

You can split a window horizontally or vertically. Let's start horizontally by pressing:

CTRL-b "

Now you have two new panes. Now vertically by pressing:

CTRL-b %

and now two more:

To move through them:

CTRL-b <Arrow keys>


I hope this tutorial has been helpful to you. As a bonus, tools such as Tmuxinator or Tmuxifier can streamline the process of creating and loading Tmux sessions, windows and panes, so that you can configure Tmux easily. Check them out if you haven't.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.

Christopher Valerio

Christopher works as a sysadmin for an American company in Costa Rica. He is a Linux enthusiast and Archlinux Lover. When he is not typing commands, he is spending time with his wife and kids or reading some cool book.

Latest posts by Christopher Valerio (see all)

8 thoughts on “How to improve your productivity in terminal environment with Tmux

    • You can remap the keys however you want. I use ` as my prefix and vim-like bindings. I couldn't live without it.

  1. Almost every Linux distro and even OS X come with the screen command, which does just about all the same stuff you're doing with Tmux, as far as I can tell. Have you used screen? If so, what are the advantages of Tmux?

    • As far as I know, Tmux is easily scriptable, so one can load pre-defined layouts more easily than screen. Not a merit for end users, but Tmux is known to have cleaner code base.

  2. Hi!
    What is the font used in the terminal window / what do you think are good terminal fonts-palette combinations.


Leave a comment

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