DEV Community

Cover image for TMUX: Terminal Multiplexer
Mohammad Ridowan Sikder
Mohammad Ridowan Sikder

Posted on

1

TMUX: Terminal Multiplexer

TMUX is a powerful tool that allows you to manage multiple terminal sessions within a single window. This guide covers the basics and some customization tips to enhance your terminal experience.

Getting Started

Installation

On Debian-based systems, you can install tmux using:

sudo apt install tmux
Enter fullscreen mode Exit fullscreen mode

Basic Usage

  1. Start a new session:
   tmux
Enter fullscreen mode Exit fullscreen mode
  1. The Prefix Key:

    • TMUX uses a prefix key to distinguish its commands from regular terminal input.
    • The default prefix is Ctrl+b. Press this before any TMUX command.
  2. Detach from a session:

    • Press the prefix, then d
  3. List all sessions:

   tmux list-sessions
Enter fullscreen mode Exit fullscreen mode
  • Or use the shortcut: prefix + s
  1. Attach to a session:
   tmux attach -t [session-name]
   # Shorthand version:
   tmux a -t [session-name]
Enter fullscreen mode Exit fullscreen mode
  • To attach to the most recent session:

    tmux a

  1. Rename a session:
    • prefix + $

Managing Panes and Windows

Panes

  • Split vertically: prefix + %
  • Split horizontally: prefix + "

  • Navigate panes: prefix + arrow keys

  • Close a pane:

    • Type exit or
    • prefix + x

Windows

  • Create a new window: prefix + c
  • Navigate windows:
    • Previous: prefix + p
    • Next: prefix + n
  • Close a window: prefix + &
  • Rename a window: prefix + ,

Customization

While TMUX works great out of the box, customizing it can improve your workflow and aesthetics.

  1. Create a config file:
   nano ~/.tmux.conf
Enter fullscreen mode Exit fullscreen mode
  1. Example customizations:
   # Use C-j and C-f as prefix keys
   set-option -g prefix C-j
   set-option -g prefix2 C-f

   # Easier window splitting
   bind-key v split-window -h
   bind-key h split-window -v
Enter fullscreen mode Exit fullscreen mode

For a quick start with great customizations, check out this popular config: gpakosz/.tmux

Remember, the beauty of TMUX lies in its flexibility. Experiment with different settings to find what works best for you. Happy multiplexing!

Billboard image

The fastest way to detect downtimes

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitoring.

Get started now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay