tmux is a terminal multiplexer that lets you create and manage multiple terminal sessions within a single window.

Let’s see it in action. Imagine you’re SSH’d into a remote server. You want to run a long-running process, but you also need to edit a config file and monitor logs.

First, start tmux:

$ tmux

This opens a new tmux session. You’ll see a green status bar at the bottom.

Now, let’s split the screen horizontally. Press Ctrl+b (your tmux prefix) then %.

+-----------------+
|                 |
|                 |
+-----------------+
|                 |
+-----------------+

You now have two panes. Let’s move to the bottom pane by pressing Ctrl+b then Down Arrow.

Split vertically with Ctrl+b then ".

+-----------------+
|                 |
+-----------------+
|       |         |
|       |         |
+-------+---------+

You have three panes. Let’s navigate between them. Ctrl+b then Left Arrow moves to the left pane. Ctrl+b then Right Arrow moves to the right pane. Ctrl+b then Up Arrow moves to the top pane.

To zoom in on a pane, making it full screen temporarily, press Ctrl+b then z. Press Ctrl+b then z again to restore the layout.

Now, let’s create a new window. Press Ctrl+b then c.

+-----------------+
|                 |
|                 |
+-----------------+

You’re in a new window, indicated by the green bar at the bottom showing 0:bash*. The previous layout is still there, accessible by pressing Ctrl+b then n (next window) or Ctrl+b then p (previous window). You can cycle through windows with Ctrl+b then n and Ctrl+b then p.

To name a window, press Ctrl+b then , (comma). You can then type a name like "logs".

To detach from a tmux session (leaving it running in the background), press Ctrl+b then d. You’ll see [detached (from session 0)]. You can reattach later by typing tmux attach or tmux a.

To list all running tmux sessions, use tmux ls.

Here’s a breakdown of essential keybindings:

Prefix Key: By default, it’s Ctrl+b. You press this before any other tmux command.

Session Management:

  • tmux new -s <session_name>: Create a new named session.
  • tmux attach -t <session_name> or tmux a -t <session_name>: Attach to an existing session.
  • tmux ls: List all sessions.
  • tmux kill-session -t <session_name>: Kill a session.
  • Ctrl+b then d: Detach from the current session.

Window Management:

  • Ctrl+b then c: Create a new window.
  • Ctrl+b then n: Go to the next window.
  • Ctrl+b then p: Go to the previous window.
  • Ctrl+b then <number>: Go to a specific window (e.g., Ctrl+b then 0 for the first window).
  • Ctrl+b then ,: Rename the current window.
  • Ctrl+b then &: Kill the current window.

Pane Management:

  • Ctrl+b then %: Split the current pane vertically.
  • Ctrl+b then ": Split the current pane horizontally.
  • Ctrl+b then <arrow key>: Move between panes (e.g., Ctrl+b then Left Arrow).
  • Ctrl+b then x: Kill the current pane.
  • Ctrl+b then o: Rotate through panes.
  • Ctrl+b then z: Zoom current pane (toggle).
  • Ctrl+b then q: Show pane numbers (press the number to select).
  • Ctrl+b then Space: Toggle layout (cycles through predefined layouts).

Copy Mode:

  • Ctrl+b then [: Enter copy mode (scroll buffer).
  • Use arrow keys or Page Up/Page Down to navigate.
  • Press Space to start selecting text.
  • Press Enter to copy the selected text to the tmux buffer.
  • Ctrl+b then ] : Paste from the tmux buffer.

Other Useful Commands:

  • Ctrl+b then ?: List all keybindings.
  • Ctrl+b then s: List sessions.
  • Ctrl+b then [: Enter copy mode to scroll up and down.

The tmux prefix Ctrl+b can be customized. Many users change it to Ctrl+a for easier access, especially if they are coming from the screen utility. You can set this in your ~/.tmux.conf file:

set -g prefix C-a
unbind C-b
bind C-a send-prefix

After saving this, you’d need to reload the config (Ctrl+b then : then source-file ~/.tmux.conf) or restart tmux.

One of the most powerful aspects of tmux is its ability to survive SSH disconnections. When you detach, your processes continue running. Reattaching later brings you back to exactly where you left off, even if you’ve connected from a different machine. This is invaluable for remote work, allowing you to pick up long-running tasks seamlessly.

Understanding tmux configuration files (~/.tmux.conf) unlocks its true potential, allowing you to tailor keybindings, status bar appearance, and session behavior to your exact workflow.

The next step is to master tmux scripting and automation for complex session setups.

Want structured learning?

Take the full Tmux course →