Operations 8 min read

Master tmux: Essential Commands and Tips for Efficient Terminal Multiplexing

This guide introduces tmux, a powerful terminal multiplexer for Linux, explains its core features, session/window/pane architecture, and provides practical command shortcuts and customization tips to keep long-running tasks running smoothly and improve workflow efficiency.

Programmer DD
Programmer DD
Programmer DD
Master tmux: Essential Commands and Tips for Efficient Terminal Multiplexing

Introduction

Frequent command‑line users often need to prevent network interruptions from breaking long‑running operations, such as multi‑hour tasks or simultaneous log monitoring. While screen and nohup are common solutions, tmux offers a richer, more flexible experience.

Core Features

Provides a strong, easy‑to‑use command‑line interface.
Supports horizontal and vertical window splitting.
Handles UTF‑8 encoding and 256‑color terminals.
Allows copy and paste across multiple buffers.
Offers an interactive menu to select windows, sessions, and clients.
Supports cross‑window searching.
Provides automatic and manual window locking.
Enables custom key‑binding configuration.

tmux Architecture

tmux (terminal multiplexer) manages multiple terminals from a single screen. Its structure consists of three layers: session , window , and pane .

Basic Usage

Because tmux is built around sessions, windows, and panes, most commands target these objects. Common actions include creating, closing, renaming, attaching, detaching, and selecting.

The default prefix key is Ctrl+b. After pressing the prefix, release it and then press the command key, e.g., prefix d to detach a session.

Session Operations

<ol>
<li><code>tmux new</code> Create a session with the default name.</li>
<li><code>tmux new -s mysession</code> Create a session named <code>mysession</code>.</li>
<li><code>tmux ls</code> List all sessions.</li>
<li><code>tmux a</code> Attach to the most recent session.</li>
<li><code>tmux a -t mysession</code> Attach to a specific session.</li>
<li><code>tmux rename -t s1 s2</code> Rename session <code>s1</code> to <code>s2</code>.</li>
<li><code>tmux kill-session</code> Close the current session.</li>
<li><code>tmux kill-session -t s1</code> Close session <code>s1</code>.</li>
<li><code>tmux kill-session -a -t s1</code> Close all sessions except <code>s1</code>.</li>
<li><code>tmux kill-server</code> Close all sessions.</li>
</ol>

Window Operations

<ol>
<li><code>prefix c</code> Create a new window.</li>
<li><code>prefix ,</code> Rename the current window.</li>
<li><code>prefix w</code> List all windows for switching.</li>
<li><code>prefix n</code> Move to the next window.</li>
<li><code>prefix p</code> Move to the previous window.</li>
<li><code>prefix l</code> Return to the last active window.</li>
<li><code>prefix 0‑9</code> Switch to the window with the corresponding number.</li>
<li><code>prefix .</code> Edit the current window index.</li>
<li><code>prefix '</code> Switch to a window with an index greater than 9.</li>
<li><code>prefix f</code> Search panes by displayed content.</li>
<li><code>prefix &</code> Close the current window.</li>
</ol>

Pane Management

<ol>
<li><code>prefix %</code> Create a pane horizontally.</li>
<li><code>prefix "</code> Create a pane vertically.</li>
<li><code>prefix Up|Down|Left|Right</code> Navigate panes using arrow keys.</li>
<li><code>prefix q</code> Show pane numbers.</li>
<li><code>prefix o</code> Rotate panes clockwise.</li>
<li><code>prefix }</code> Swap with the next pane.</li>
<li><code>prefix {</code> Swap with the previous pane.</li>
<li><code>prefix x</code> Close the current pane.</li>
<li><code>prefix Space</code> Rearrange all panes in the current window.</li>
<li><code>prefix !</code> Move the current pane to a new window.</li>
<li><code>prefix Ctrl+o</code> Rotate panes counter‑clockwise.</li>
<li><code>prefix t</code> Show time in the current pane.</li>
<li><code>prefix z</code> Toggle zoom for the current pane.</li>
<li><code>prefix i</code> Display information about the current pane.</li>
</ol>

Custom Configuration

After installing tmux, you can edit ~/.tmux.conf to fine‑tune its behavior. A popular macOS configuration is available at github.com/gpakosz/.tmux .

Conclusion

This article serves as a practical “how‑to” guide. Readers are encouraged to explore additional tmux features—such as mouse support—to further boost productivity.

Session Managementtmuxterminal multiplexing
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.