Sep 152011

In a former article i’ve show how to use Screen and Byobu, in short Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells) while Byobu is an elegant enhancement of the otherwise functional, plain, practical GNU Screen. Byobu includes an enhanced profile and configuration utilities for the GNU screen window manager, such as toggle-able system status notifications.

But today we’ll see something similar, but different: Tmux

Like Screen tmux is a terminal multiplexer: it enables a number of terminals (or windows), each running a separate program, to be created, accessed, and controlled from a single screen. tmux may be detached from a screen and continue running in the background, then later reattached.

Among the most notable features of tmux there are:

  • The use of commands that use syntax-like vi or emacs,
  • The possibility to copy/paste between created terminals (panels)
  • Total customization through the file ~ /.tmux.conf

tmux runs as a server-client system. A server is created automatically when necessary and holds a number of sessions, each of which may have a number of windows linked to it. Any number of clients may connect to a session, or the server may be controlled by issuing commands with tmux. Communication takes place through a socket, by default placed in /tmp.



tmux is usually availabe in all the official Linux distribution repository, so i’ve installed it on my ubuntu 11.04 with

aptitude install tmux

This has installed for me the release 1.3-2+squeeze1

Basic usage

In a terminal just write tmux and you’ll start it.
Now you can use a combination of keys to get some results, the most commons/useful i’ve saw so far are:

CTRL + b This combination it’s the default to tell tmux you are about to issue a command
CTRL + b " Split the current pane into two, top and bottom.
CTRL + b % Split the current pane into two, left and right.
CTRL + b arrow using the arrows you can change to the pane above, below, to the left, or to the right of the current pane
CTRL + b x Kill the current pane.
CTRL + b c Create a new window
CTRL + b l Move to the previously selected window.
CTRL + b n Move to the next window.
CTRL + b d Detach the client

Finally, I would like to nominate the copy & paste feature which I think is a really useful. To enter the Copy mode all you have to do is Ctrl + b [ and move up to what needs to be copied. Then press Ctrl + Space and select the text. Once selected, copy with Alt + w . To paste the text all you have to do is Ctrl + b ].

Once that you detach from tmux you’ll be back on terminal. From here you can use these commands:

1) List all sessions managed by the server with the parameter ls

#tmux ls 
0: 2 windows (created Thu Sep 15 12:46:14 2011) [203x50]

#tmux attach -t 0

This will return your terminal to your detached session.

3) Destroy the given session, closing any windows linked to it and no other sessions, and detaching all clients attached to it with the parameter kill-session -t # of session

#tmux ls 
0: 2 windows (created Thu Sep 15 12:46:14 2011) [203x50]
#tmux kill-session -t 0

This will close the session and all the windows in our formerly detached session.


These are only the main options of tmux, check the man page for some more, this can be a great program to be used on server without graphical terminals, personally on desktops I still prefer to use smart terminal programs like terminator, they do perhaps less things but you don’t have to remember all the combinations of keys, and for a PC that your turn on and off every day it’s enough.
Regarding that in tmux you can customise all the combinations so they can be more user friendly.

Popular Posts:

Flattr this!

  2 Responses to “Tmux – the Terminal multiplexer”

  1. I have used Screen a lot, but once I learned about Tmux, I never went back.

  2. And it perfectly fits my 256 color terminal setup:
    <a href="; title="tmux.conf 256 color values"
    <a href="; title="tmux 256 color screenshot"

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>