01. Introduction to tmux & Installation

Why tmux?

Let's face it - you're a busy person. When you surf the net, you have at least five tabs open. In one tab, you have Debussy's Clair de lune playing as background music, while in another, you have 10 messages from Facebook friends who want to catch up with you. And then you're on Reddit, get up-to-date with the latest tech news and cat memes. And finally, here, you're studying to be a pro-Linux users so you can swoon the ladies. Modern day browsers allow you to multi-task and organize your workspace within the same windows - how convenient!

Multiple tabs open in Google Chrome browser.
Multiple tabs open in Google Chrome browser.

But does the terminal offer similar features? With tmux (short for terminal multiplexer), Yes! As defined on its official website, tmux enables a number of terminals, each running a separate program to be created, accessed and controlled from a single screen.

Advantages of Using tmux

"But wait!" I hear you say, "I already have iTerm installed on my Mac OS X, which allows me to create new tabs and split window panes. Do I still need to learn tmux?" iTerm is great in that it gives you a slew of features for customizing and making the most out of the terminal. However, once you leave your precious Mac OS X (such as SSHing into a Linux machine), you've lost all your iTerm features.

Tmux, on the other hand, is completely portable, and its features are available from within any UNIX-like command line! Furthermore, there are other advantages of tmux that trumps the use of a natively installed terminals.

  • Multi-tasking: You can use one pane to display all current processes (using something like top), while other windows can be used to administer actual commands.
  • Availability: tmux is a shell program, meaning it can be installed and run directly within the command line. This allows you to run tmux on remote servers.
  • Multiple interfaces: There's no need to open up multiple terminal interfaces and SSH into a host server from each one to have multiple command lines.
  • Persistence: All tmux sessions can be saved in-state as sessions. So if you're at an airport working on important files on a remote server and your flight is about to take off, you can save exactly where you were and come back to it once you've landed.
  • Shareable: You may share sessions, meaning if someone else is logged in with you, you can see what the other is typing. This can be useful for paired programming, which is a technique where one programmer suggests to the other what to do, while the other programmer runs the commands.
  • The WOW factor: You'll look like a pro Linux user to any onlookers.


Before getting to the actual commands, let's install tmux from either a remote server or your local computer.

If you're running Mac OS X, grab the Homebrew Package Mananger, and run a simple brew install command.

$ brew install tmux

On Ubuntu, use apt-get, and for CentOS, use yum. For arch, use pacman

# Debian based (Ubuntu)
$ sudo apt-get install tmux
# CentOS or Fedora
$ sudo yum install tmux
# Arch
$ sudo pacman -S tmux

Getting Started with tmux

Now if you type tmux on the command line, you should have a tmux session running, as indicated by a green status bar at the bottom of the window. Before we move on, print out any tmux cheatsheet and tape it to your wall next to the monitor.

New tmux session with a green status bar at the bottom
New tmux session with a green status bar at the bottom

Sessions, Windows and Panes

tmux separates each terminal interface into three categories: sessions, windows and panes. Panes are parts of a window, while windows make up a session. By separating multiple interfaces in three different layers, we're able to better organize our workspace.

Tmux organizes its terminals into sessions, windows and panes.
Tmux organizes its terminals into sessions, windows and panes.

Keystrokes and Prefix Key

tmux comes with subcommands that are bound to certain keys. Below is the help page, where you can see the list of special keys.

A complete listing of all available keystrokes by typing in the question mark.
A complete listing of all available keystrokes by typing in the question mark. To access this page, run tmux and type <Ctrl-b> ?.

Before typing in any special key, you must input the prefix. By default, tmux's prefix is Ctrl-b. So for example, if we want to split a window horizontally, we type <Ctrl-b>, then %. There is a way in which we may change the prefix, which we'll discuss later in our configurations lesson. But for now, let's move onto how we can manage panes!

Aching back from coding all day?

Prism Glasses

Aching back from coding all day? Try Back Problems

Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.

$ Check price
4.454.45Amazon 4 logo(128+ reviews)

More Back Problems resources

Take your Linux skills to the next level!

Linux for Beginners

Take your Linux skills to the next level! Try Linux & UNIX

Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.

$ Check price
24.9924.99Amazon 4.5 logo(101+ reviews)

More Linux & UNIX resources