TMUX Terminal Multiplexer Tutorial

tmux is similar to screen as it lets you run numerous TTY’s in the same terminal window. It supports some very cool and intuitive features natively as well as a much more readable configuration syntax (ever looked at a .screenrc file?).

Why TMUX over Screen?

Well according to the FAQ for tmux it has the following advantages over screen:

  • A clearly defined cilent/server model (windows are their own clients which allows flexibility on how you handle windows. You can attach and detach different windows in different sessions without any issues)
  • Consistent, well-documented command interface. (You can use the same commands interactively as in the .tmux.conf file, more on that later)
  • Easily scriptable
  • Multiple paste buffers
  • Vi & Emacs keybindings
  • A more usable status line syntax (which also allows you to embed the output of a shell command, handy indeed.

Default keybindings & Functionality

The default keybindings for tmux are actually pretty intuitive, though if you’re used to screen you’ll likely get a little peeved with the default action binding of C-b, though this is easily changed to mimic screens behavior:

*NOTE* You can change keybinding Ctrl-b to Ctrl-a by creating a ~/.tmux.conf and putting the following into it: set -g prefix Ctrl-a . There is no tmux.conf by default.

  • Ctrl-b c Create new window
  • Ctrl-b d Detach current client
  • Ctrl-b l Move to previously selected window
  • Ctrl-b n Move to the next window
  • Ctrl-b p Move to the previous window
  • Ctrl-b & Kill the current window
  • Ctrl-b , Rename the current window
  • Ctrl-b % Split the current window into two panes
  • Ctrl-b q Show pane numbers (used to switch between panes)
  • Ctrl-b o Switch to the next pane
  • Ctrl-b ? List all keybindings

Now these are pretty self explanatory – the real magic (for me) of tmux is the ease of modifying the default behavior to do what you want, but first things first: let’s explore the default behavior of tmux.

Basic Window Handling

Start up tmux with the tmux command and you should be greeted with a simplistic terminal window that resembles screen – the only difference is it has a default status bar which is nice (easily added to screen as well).


Now let’s create a couple of windows and go through them (we’ll be using the default bindings). Hit Ctrl-b c a few times to create a few windows, you should notice that there are more tabs in the status bar.

Now if you’re like me you like to have descriptive names of which each window is for, so let’s rename them by hitting Ctrl-b ,. It should prompt you to rename the current window – type anything you want and hit enter. Now the current window is renamed to what you specified. Now going forward I’m going to have two windows open respectively named “window1″ and “window2″.

Once you rename your windows lets switch back and forth. We have several different ways of switching windows, so I’ll go over the ones I personally use:

  • Ctrl-b n (Move to the next window)
  • Ctrl-b p (Move to the previous window)
  • Ctrl-b l (Move to the previously selected window)
  • Ctrl-b w (List all windows / window numbers)
  • Ctrl-b <window number> (Move to the specified window number, the default bindings are from 0 – 9)

Now these ones fairly self explanatory however they don’t really cater to a lot of different windows. What if you have 10+ windows open? It becomes quite tedious to find the window you want – but don’t fret! Tmux has a find-window option & keybinding. Type Ctrl-b f and type in the window name you want (it actually searches for the window so you can type in only part of the name of the window you’re looking for).

You can also get a list of the windows in the current session by executing the list-windows command. To execute commands interactively you type Ctrl-b : which will bring up a text prompt. From there you can execute any command tmux supports interactively (tab completion is supported).

Basic Pane Handling

One of the most powerful features tmux offers is the ability to split up your current window into “panes”. Anyone whose familiar with tiling windows managers will feel quite at home. It’s a bit difficult to explain this in words so a simple screenshot will suffice:


Now here are some basic key bindings and commands to split the terminal window (vertically and horizontally) and to switch between them

  • Ctrl-b % (Split the window vertically)
  • Ctrl-b : “split-window” (Split window horizontally)
  • Ctrl-b o (Goto next pane)
  • Ctrl-b q (Show pane numbers, when the numbers show up type the key to goto that pane)
  • Ctrl-b { (Move the current pane left)
  • Ctrl-b } (Move the current pane right)

Now some obviously the default bindings don’t encompass some of features, such as splitting horizontally. I personally rebind the keys so “|” splits the current window vertically, and “-” splits it horizontally. Not the easiest things to type, though easy to remember.

You can achieve this by putting the following in ~/.tmux.conf or by typing it in the interactive prompt (Ctrl-b :). Keep in mind if you do the latter it will only be in effect for that session:

unbind %
bind | split-window -h
bind – split-window -v

Advanced Window Handling

Now that we went over the basics lets dive a little deeper into some “advanced” features of tmux. This includes moving windows around, linking windows together, switching windows from different sessions and much more. By default tmux doesn’t have key bindings for these features, so we’ll be entering them in the interactive dialog (accessed by typing Ctrl-b :) – keep in mind tmux is very scriptable and you can easily create your own key bindings for all of these.

Moving Windows

Now if you want to move a window you can use the move-window command. The command to do this:

move-window [ −d] [ −s src-window] [ −t dst-window]
swap-window [ -d] [ -s src-window] [ -t dst-window]

Similar to the above command except both windows have to exist – if they both do the window with the ID source and destination windows will be swapped.

Advanced Pane Handling

When you split up a window into multiple smaller windows they’re referred to as panes. Tmux also offers “layouts” for the panes, or the default positioning and behavior when you create a new window. You can switch through the panes by using the key binding Ctrl-b <space> which will toggle through the different layouts. Each one has different behaviors such as main-vertical which means the current active pane will take up more space in the current window, or even-vertical which will split the panes equally. Since this is difficult to describe in text I believe a few screen shots are in order:




Now that you’ve seen the different layouts let’s see what we can do with these panes. As mentioned above in the “Pane Handling” section you can switch through panes by issuing the Ctrl-b o key combination (which is using the down-pane command) or by typing Ctrl-b q which will list the pane ID’s and you select the one you want.

Make your pane into its own window

If you want to take a pane and make it into its own window you do the following:

Ctrl-b : “break-pane”

Simple enough, you should now have the pane in its brand new window. If you don’t want it to automatically make the pane you just broke out as the active window issue the “-d” switch which will simply break the pane to a new window but keep you in the current window.

Resizing Panes

You can also resize panes if you don’t like the layout defaults. I personally rarely need to do this, though it’s handy to know how. Here is the basic syntax to resize panes:

Ctrl-b : resize-pane (By default it resizes the current pane down)
Ctrl-b : resize-pane -U (Resizes the current pane upward)
Ctrl-b : resize-pane -L (Resizes the current pane left)
Ctrl-b : resize-pane -R (Resizes the current pane right)
Ctrl-b : resize-pane 20 (Resizes the current pane down by 20 cells)
Ctrl-b : resize-pane -U 20 (Resizes the current pane upward by 20 cells)
Ctrl-b : resize-pane -L 20 (Resizes the current pane left by 20 cells)
Ctrl-b : resize-pane -R 20 (Resizes the current pane right by 20 cells)
Ctrl-b : resize-pane -t 2 20 (Resizes the pane with the id of 2 down by 20 cells)
Ctrl-b : resize-pane -t -L 20 (Resizes the pane with the id of 2 left by 20 cells)
… etc

Hopefully you get the jist – don’t get confused! Simply load up a tmux session and split the window a couple of times and issue the above commands. It should become fairly evident how it behaves after fiddling with it for a bit.

Utilizing the client / server model

I’ve avoided mentioning that a lot of these commands can actually be applied to numerous tmux sessions which allows quite a bit of flexibility – the reason for avoiding it is it’s too much information all at once! An example of using this functionality is if you have two sessions open you can “link” or “move” windows across different sessions – unfortunately the actual “how-to” will be in Part 2.


Tmux may be a bit confusing however it’s worth putting in a few minutes to check it out and see what it has to offer – quick easy and intuitive.

Original Source:

This entry was posted in Linux, Computers, etc and tagged , , , . Bookmark the permalink.

15 Responses to TMUX Terminal Multiplexer Tutorial

  1. Eric Lake says:

    Nice overview of tmux. I have started using it in place of screen and this tutorial helped with that migration. I am looking forward to Part 2.

  2. OK, now how do you create a bunch of windows/panes from a tmux configuration file? If I stick the commands into a file and do “tmux -f whatever.tmux”, nothing happens. But then when I quit tmux and run “tmux attach”, I see my windows/panes. What am I doing wrong?

  3. Lalo says:

    Thank you for the intro, I think you can split windows (horizontaly) by doing C-b and then ” instead of C-b: split-window, I like the | and – alternatives better. Now I’ll read the man page :).

  4. Sébastien says:

    I’m using tmux without having used screen before, always thought it might be too tough for me. I’m very pleased with tmux, using ssh a lot it helps very much.

    Could you tell me what are the two top panes running, on your first screenshot?

    • Jeff says:

      OK sure,

      The programs are htop, iftop, and iotop in that order top to bottom.

      Do a search for “Linux terminal programs” sometime when you have some time to kill.
      My first such search resulted in more available than I would have ever thought!

  5. Robert Daeley says:

    (Edit by Jeff): Spam filter didn’t like your original comment with ping back.

    A Tmux review by Robert Daeley at

  6. Marcel Dorenbos says:

    I use tmux for a while now to connect to multiple systems at the same time. I automatically rename the windows using the following (bash) logic:

    tmux rename-window “Start $host”
    ssh $host
    tmux rename-window “End $host”

    So in the tab name I can see which host I connect to, and in which state it is. Well, that is actually how I thought it would work, but tmux will not rename the session from which the command was given, instead it is renaming the window which is active.

    I have been looking in the man pages and on the web, but it seems to be impossible to rename “this window” instead of the active window.

    Do you have any suggestions here?


    • Marcel Dorenbos says:

      I am now using a sort of workaround, which is to rename the window to something unique, find out using the /tmux list-windows/ command what the window number is, and than rename the windows using this number.

  7. RP says:

    I like tmux, it’s strong and easygoing. The problem is that I could alias “irssi” to “screen irssi” and jump directly into screen :) I can’t do that with tmux, unfortunately. That doesn’t stop me from using it, though. If there’s any suggestion of how I can start an app with tmux directly, it’s welcome.

  8. rking says:

    Hi! Sweet tutorial; I’m thinking about linking to it from tweemux.

    I’d like to talk about a few details, but before I get into it I figure I’ll test the waters and see if you’re interested in some feedback.

    The first thing I’d ask if you’d be OK with removing the “unbind %”. Yes, it’s an awkward mapping, but my opinion is that the default keys should usually be left alone, because if you’re pair programming with someone that isn’t used to your config, it can be surprising.

    What do you think?


  9. Shane Hudson says:

    I’ve been meaning to use tmux for years and have now finally set it up, thanks for your help.

  10. Luca Profico says:

    Thanks a lot. After 4 years, I still come back to this page when I forget a shortcut :)

Leave a Reply

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

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=""> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">