Mastering tmux: The Ultimate Terminal Multiplexer Guide

Listen to this Post

tmux (Terminal Multiplexer) is a powerful tool for managing multiple terminal sessions within a single window. It’s indispensable for remote work, scripting, and sysadmin tasks, ensuring sessions persist even if connections drop.

You Should Know:

1. Install tmux

  • Linux (Debian/Ubuntu):
    sudo apt update && sudo apt install tmux -y 
    
  • macOS (Homebrew):
    brew install tmux 
    
  • Windows (WSL):
    sudo apt install tmux 
    

2. Basic tmux Commands

  • Start a new session:
    tmux new -s mysession 
    
  • Detach from session (keeps it running):
    Ctrl + b, d 
    
  • Reattach to a session:
    tmux attach -t mysession 
    
  • List active sessions:
    tmux ls 
    

3. Split Panes & Windows

  • Vertical Split:
    Ctrl + b, % 
    
  • Horizontal Split:
    Ctrl + b, " 
    
  • Switch between panes:
    Ctrl + b, arrow keys 
    
  • Create a new window:
    Ctrl + b, c 
    

4. Advanced Usage

  • Scroll Mode:
    Ctrl + b, [ 
    

(Exit with `q`)

  • Copy-Paste:

Enable mouse mode in `~/.tmux.conf`:

set -g mouse on 

– Session Sharing:

Allow multiple users to join:

tmux new -s shared -S /tmp/shared 
chmod 777 /tmp/shared 

5. Persistence & Scripting

  • Run a command in a detached session:
    tmux new -d -s script 'while true; do echo "Running..."; sleep 1; done' 
    
  • Kill a session:
    tmux kill-session -t mysession 
    

What Undercode Say:

tmux is a game-changer for terminal productivity. Pair it with:
– `screen` (fallback if tmux isn’t available).
– `htop` for process monitoring in splits.
– `rsync` for background transfers in tmux sessions.
– `vim` or `nano` for editing configs without losing context.

For automation, combine tmux with `cron` or `systemd` to maintain long-running tasks.

Expected Output:

A resilient, multi-tasking terminal environment with persistent sessions, split layouts, and seamless remote workflow integration.

Further Reading:

References:

Reported By: Chuckkeith Tmux – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image