Serious Discussion Tmux for Beginners: Supercharge Your Terminal!

Divergent

Level 22
Thread author
Verified
Jul 26, 2025
1,150
3,422
2,068
Hey everyone,

Ever been SSH'd into a remote server, running a long command, and then your internet drops? Or maybe you just wish you could organize your terminal sessions better without opening a dozen different windows? If so, you need to check out tmux!

Tmux (short for "terminal multiplexer") is an incredibly powerful tool that lets you create and manage multiple, persistent terminal sessions from a single window. Think of it like a window manager for your command line.

This guide will get you started with the basics. Trust me, once you go tmux, you won't go back!

Why Tmux for Security Folks?​

Beyond general productivity, tmux is a game-changer for anyone doing security work, especially on remote systems:
  • Persistence: Your sessions live on the server even if you disconnect. Great for long scans, exploits, or data transfers that you don't want interrupted.
  • Organization: Keep your reconnaissance, exploitation, and post-exploitation steps in separate, easily accessible panes or windows within one terminal.
  • Collaboration: Multiple users can attach to the same tmux session (with caution and proper permissions, of course!).
  • Demonstrations: Prepare your terminal exactly how you want it for demos or presentations, splitting screens for various outputs.

Getting Started: Installation​

First things first, you need to install tmux. It's usually in your distribution's package manager:

On Debian/Ubuntu:

Bash

sudo apt update
sudo apt install tmux

On Fedora/RHEL/CentOS:

Bash

sudo dnf install tmux

On macOS (with Homebrew):

Bash

brew install tmux

The Absolute Basics: Your First Session​

Once installed, fire it up!
  1. Start a new session:
    Bash

    tmux

    You'll notice your terminal might look slightly different, possibly with a green bar at the bottom. Congratulations, you're in a tmux session!
  2. The "Prefix Key" - Your Gateway to Control: Almost all tmux commands start with a special key combination called the prefix key. By default, this is: Ctrl+b
    You'll press Ctrl+b first, release both keys, and then press the command key.
  3. Detaching from a Session:This is crucial! When you want to leave your tmux session running in the background (e.g., to close your SSH connection but keep your processes alive), use:
    • Press Ctrl+b
    • Then press d (for "detach")
    • You'll be returned to your regular terminal, and tmux will tell you the session name (e.g., [detached (from session 0)]).

  4. Reattaching to a Session: To get back into your running session:
    Bash

    tmux attach

    If you have multiple sessions (we'll get to that!), you might need to specify which one:
    Bash

    tmux attach -t 0 # attach to session 0

    Or, to see a list of sessions:
    Bash

    tmux ls

    Then tmux attach -t <session_name_or_number>

Navigating Within Tmux: Windows and Panes​

Tmux lets you organize your work in two main ways: windows and panes.
  • Windows: Think of these like tabs in a web browser. Each window can run a completely different set of commands.
  • Panes: Think of these like splits within a single tab. You can divide a window into multiple rectangular areas, each running its own shell.

Window Commands (after Ctrl+b prefix):​

  • c: Create a new window.
  • p: Go to the previous window.
  • n: Go to the next window.
  • <number>: Go to a specific window by its number (e.g., Ctrl+b 0 for the first window).
  • ,: Rename the current window (helpful for organization!).
  • &: Kill the current window (it will ask for confirmation).

Pane Commands (after Ctrl+b prefix):​

  • ": Split the current pane horizontally (new pane below).
  • %: Split the current pane vertically (new pane to the right).
  • o: Move to the next pane in the current window.
  • <arrow key>: Move to a pane in the direction of the arrow (e.g., Ctrl+b then Up Arrow).
  • x: Kill the current pane (it will ask for confirmation).
  • z: Zoom current pane to fill the entire window (press Ctrl+b z again to unzoom).

A Simple Workflow Example​

  1. Start tmux: tmux
  2. Split horizontally for notes: Ctrl+b "
  3. Move to the bottom pane: Ctrl+b o
  4. Split vertically for a scan: Ctrl+b %
  5. Move to the right pane: Ctrl+b o
  6. Create a new window for a different task: Ctrl+b c
  7. Rename the window: Ctrl+b , then type "Exploit Prep" and hit Enter.
  8. Detatch: Ctrl+b d
  9. Later, reattach: tmux attach

Customization (The .tmux.conf File)​

Tmux is highly customizable! You can change keybindings, status bar appearance, and much more by creating a .tmux.conf file in your home directory (~/.tmux.conf).

A common first customization is to change the prefix key to Ctrl+a because Ctrl+b can conflict with other shortcuts.

Add this to your ~/.tmux.conf file:

Code snippet

# Set prefix key to Ctrl+a
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix

# Enable mouse mode (scrolling, pane resizing with mouse)
set -g mouse on

After saving, you need to "source" the config file or restart tmux:
  • Source: In a tmux session, press Ctrl+b then : (colon), then type source-file ~/.tmux.conf and press Enter.
  • Restart: Detach from all sessions (tmux kill-server) and then start tmux again.

Where to Go Next?​

This is just the tip of the iceberg! Tmux has many more features:
  • Session Naming: Give your sessions meaningful names (e.g., tmux new -s pentest-clientX).
  • Copy/Paste Mode: Yes, you can copy text from tmux! (Ctrl+b [ to enter copy mode, then navigate, select with Space, copy with Enter).
  • Scrollback Buffer: Review past output.
  • Plugins: Extend functionality with community plugins (e.g., tpm - Tmux Plugin Manager).
Resources:
  • Official Man Page: man tmux (it's dense but comprehensive)
  • Tmux Cheat Sheet: Search online for "tmux cheat sheet" – many great visual aids.
  • YouTube Tutorials: Plenty of excellent video guides.
Start incorporating tmux into your daily workflow, and you'll quickly realize how essential it becomes for efficient and persistent terminal work.