Skip to main content

Your First tmux Session

Let’s get you productive with tmux quickly. This guide covers the essential concepts and commands you’ll use daily.
1

Start tmux

Open your terminal and start your first tmux session:
You’ll see a new shell prompt with a green status bar at the bottom showing:
  • [0] - session name
  • 0:bash* - window number and name
  • Your hostname and time on the right
2

Understand the prefix key

All tmux commands start with a prefix key: C-b (Ctrl-b)
Press Ctrl and b together, release both keys, then press the command key. For example, C-b c means: press Ctrl-b, release, then press c.
The prefix key tells tmux: “I’m about to give you a command, not the shell.”
3

Create a new window

Press C-b c to create a new window.Notice the status bar now shows:
The * indicates your current window. The - marks the previous window.
4

Navigate between windows

Try these navigation commands:
  • C-b n - next window
  • C-b p - previous window
  • C-b 0 - switch to window 0
  • C-b 1 - switch to window 1
  • C-b l - toggle between current and last window
5

Split into panes

Now let’s split a window into multiple panes:
  • C-b % - split vertically (left and right)
  • C-b " - split horizontally (top and bottom)
Each pane is an independent terminal.
6

Navigate between panes

Move between panes:
  • C-b o - cycle to next pane
  • C-b ↑ - move to pane above
  • C-b ↓ - move to pane below
  • C-b ← - move to pane on left
  • C-b → - move to pane on right
  • C-b ; - move to previously active pane
7

Detach from session

Press C-b d to detach from the session.You’ll see a message:
Your session is still running in the background! All your windows and panes are preserved.
8

Reattach to session

Return to your session with:
Everything is exactly as you left it.

Essential Commands Reference

1

Enter copy mode

Press C-b [ to enter copy mode and scroll through history.You’ll see [0/0] in the top-right corner showing your position in history.
2

Navigate in copy mode

Emacs mode (default):
  • Arrow keys - move cursor
  • C-Space - begin selection
  • M-w - copy selection
  • C-g - exit copy mode
Vi mode (if set -g mode-keys vi in config):
  • h/j/k/l - move cursor
  • Space - begin selection
  • Enter - copy selection
  • q - exit copy mode
3

Paste

Press C-b ] to paste the most recently copied text.
Use Page Up as a shortcut to enter copy mode and scroll up one page immediately.

Practical Workflow Example

Here’s a common development workflow:
1

Create a development session

2

Set up your layout

  • Start in your project directory
  • Press C-b % to split vertically
  • In the right pane, press C-b " to split horizontally
You now have three panes:
3

Run your development tools

  • Left pane: Open your editor (vim, nano, etc.)
  • Top-right pane: Run your test watcher
  • Bottom-right pane: Tail your application logs
4

Detach when done

Press C-b d to detach. Your session keeps running.
5

Return later

Everything is still running!

Remote Development Workflow

One of tmux’s most powerful features is persistence over SSH:
1

SSH to remote server

2

Start or attach to tmux

3

Do your work

Start long-running builds, tests, or processes.
4

Disconnect safely

Press C-b d to detach, then exit SSH:
Your tmux session keeps running on the server!
5

Reconnect anytime

Pick up exactly where you left off.
If your SSH connection drops unexpectedly, tmux automatically detaches. Your session and all running processes continue uninterrupted.

Basic Configuration

Create ~/.tmux.conf to customize tmux:
After creating or editing the config:

Common Patterns

Both users need access to the same server and tmux socket. This is useful for pair programming or collaborative debugging.

Troubleshooting

Add to your shell configuration (.bashrc, .zshrc):
And in ~/.tmux.conf:
Enable mouse support in ~/.tmux.conf:
Then reload config: C-b : source-file ~/.tmux.conf

Next Steps

Key Bindings

Press C-b ? inside tmux to see all default key bindings, or explore customization options.

Configuration

Learn advanced configuration options in ~/.tmux.conf including status bar customization, custom key bindings, and hooks.

Command Reference

Read the manual page (man tmux) for complete command documentation and options.

Community Resources

Join the tmux community at https://github.com/tmux/tmux for plugins, themes, and support.
The quickest way to learn is to practice! Try using tmux for your next project and the key bindings will become second nature.