DEV Community

Cover image for The Only tmux Cheat Sheet You'll Need as a Developer
coder7475
coder7475

Posted on

The Only tmux Cheat Sheet You'll Need as a Developer

If you spend time working on remote servers, running long-lived processes, or managing multiple terminals, tmux is one of the most valuable tools you can learn.

It allows you to keep terminal sessions alive even after disconnecting from SSH, split your terminal into multiple panes, organize work into windows, and switch between projects without opening dozens of terminal tabs.

This article is a practical cheat sheet covering the commands I use every day.


What is tmux?

tmux (Terminal Multiplexer) lets you create persistent terminal sessions.

Instead of opening multiple terminal windows, you can organize everything inside a single terminal.

Typical use cases:

  • Remote server administration
  • Backend development
  • Running long-lived processes
  • Docker and Kubernetes management
  • DevOps workflows
  • Multiple SSH connections

Sessions

A session is your workspace.

Think of it as a project that contains multiple windows and panes.

List sessions

tmux ls
# or
tmux list-sessions
Enter fullscreen mode Exit fullscreen mode

Example:

backend: 2 windows
devops: 4 windows
Enter fullscreen mode Exit fullscreen mode

Create a session

tmux new -s backend
Enter fullscreen mode Exit fullscreen mode

Create a detached session

Useful for starting background services.

tmux new -d -s backend
Enter fullscreen mode Exit fullscreen mode

Attach to a session

tmux attach -t backend

## Short version
tmux a -t backend
Enter fullscreen mode Exit fullscreen mode

Detach from a session

Press

Ctrl+b d
Enter fullscreen mode Exit fullscreen mode

Everything continues running.


Create or attach (my favorite)

Instead of remembering whether the session already exists:

tmux new -As backend
Enter fullscreen mode Exit fullscreen mode

This creates the session if needed or attaches to it if it already exists.


Rename a session

tmux rename-session -t backend api
Enter fullscreen mode Exit fullscreen mode

Or inside tmux:

Ctrl+b $
Enter fullscreen mode Exit fullscreen mode

Kill a session

tmux kill-session -t backend
Enter fullscreen mode Exit fullscreen mode

Kill every session:

tmux kill-server
Enter fullscreen mode Exit fullscreen mode

Windows

A window is similar to a browser tab.

One session can contain many windows.

Create a new window

Ctrl+b c
Enter fullscreen mode Exit fullscreen mode

List windows

Ctrl+b w
Enter fullscreen mode Exit fullscreen mode

Next / Previous window

Ctrl+b n
Enter fullscreen mode Exit fullscreen mode
Ctrl+b p
Enter fullscreen mode Exit fullscreen mode

Jump directly

Ctrl+b 0
Ctrl+b 1
Ctrl+b 2
...
Enter fullscreen mode Exit fullscreen mode

Rename window

Ctrl+b ,
Enter fullscreen mode Exit fullscreen mode

Close window

Ctrl+b &
Enter fullscreen mode Exit fullscreen mode

Panes (Split Terminals)

Panes let you divide a window into multiple terminals.


Vertical split

Creates left/right panes.

Ctrl+b %
Enter fullscreen mode Exit fullscreen mode
+-----------+-----------+
|           |           |
|           |           |
+-----------+-----------+
Enter fullscreen mode Exit fullscreen mode

Horizontal split

Creates top/bottom panes.

Ctrl+b "
Enter fullscreen mode Exit fullscreen mode
+-----------------------+
|                       |
+-----------------------+
|                       |
+-----------------------+
Enter fullscreen mode Exit fullscreen mode

Navigate Between Panes

Arrow keys:

Ctrl+b ←
Ctrl+b →
Ctrl+b ↑
Ctrl+b ↓
Enter fullscreen mode Exit fullscreen mode

Cycle through panes:

Ctrl+b o
Enter fullscreen mode Exit fullscreen mode

Show pane numbers:

Ctrl+b q
Enter fullscreen mode Exit fullscreen mode

Resize Panes

Using the keyboard:

Ctrl+b Alt+Arrow
Enter fullscreen mode Exit fullscreen mode

Or command mode:

Ctrl+b :

resize-pane -L 10
resize-pane -R 10
resize-pane -U 5
resize-pane -D 5
Enter fullscreen mode Exit fullscreen mode

Zoom a Pane

Need temporary full-screen?

Ctrl+b z
Enter fullscreen mode Exit fullscreen mode

Press again to restore.


Change Layout

Cycle through built-in layouts.

Ctrl+b Space
Enter fullscreen mode Exit fullscreen mode

Very useful when several panes become cluttered.


Close a Pane

Simply exit the shell.

exit
Enter fullscreen mode Exit fullscreen mode

or

Ctrl+d
Enter fullscreen mode Exit fullscreen mode

Enable Mouse Support

Add this to your ~/.tmux.conf

set -g mouse on
Enter fullscreen mode Exit fullscreen mode

Reload:

tmux source-file ~/.tmux.conf
Enter fullscreen mode Exit fullscreen mode

Now you can:

  • Click panes
  • Resize panes
  • Scroll normally
  • Select windows with the mouse

Run Commands in Background

Launch a process without attaching.

tmux new -d -s api "npm run dev"
Enter fullscreen mode Exit fullscreen mode

or

tmux new -d -s server "python app.py"
Enter fullscreen mode Exit fullscreen mode

Perfect for servers and CI scripts.


A Typical Development Workflow

Suppose you're working on a backend application.

Session: backend
│
├── Window 0: Editor
│   ├── Neovim
│   ├── npm run dev
│   └── Logs
│
├── Window 1: Database
│   ├── PostgreSQL
│   └── Redis
│
└── Window 2: Monitoring
    ├── htop
    └── Docker logs
Enter fullscreen mode Exit fullscreen mode

Everything stays organized inside a single tmux session.

Disconnect from SSH?

No problem.

Reconnect later:

tmux attach -t backend
Enter fullscreen mode Exit fullscreen mode

Everything is exactly where you left it.


Daily Cheat Sheet

Action Shortcut / Command
New session tmux new -s name
Attach tmux a -t name
Create or attach tmux new -As name
List sessions tmux ls
Detach Ctrl+b d
New window Ctrl+b c
Window list Ctrl+b w
Next window Ctrl+b n
Previous window Ctrl+b p
Vertical split Ctrl+b %
Horizontal split Ctrl+b "
Switch panes Ctrl+b + Arrow Keys
Next pane Ctrl+b o
Zoom pane Ctrl+b z
Change layout Ctrl+b Space
Show pane numbers Ctrl+b q
Close pane Ctrl+d
Close window Ctrl+b &
Kill session tmux kill-session -t name

Final Thoughts

Learning tmux takes a little practice, but once it becomes part of your workflow, it's hard to imagine working without it—especially when developing on remote servers or juggling multiple services.

Start with just a few shortcuts:

  • Ctrl+b d
  • Ctrl+b c
  • Ctrl+b %
  • Ctrl+b "
  • Ctrl+b z
  • Ctrl+b o

Master those, and you'll already be more productive than constantly opening and switching between terminal tabs.

Top comments (0)