When I first started my career, Tmux quickly became my go-to tool for working with Linux servers. Its most powerful feature? It lets me keep tasks running in the background even after I disconnect from the network. Plus, it allows me to manage multiple workspaces inside a single terminal window, which is a huge boost to my productivity.
This cheatsheet covers the most common Tmux commands I use every day. It’s not a full-blown tutorial, but a quick reference guide to help you recall and use these commands whenever you need them.
Table of contents
Open Table of contents
How to Install Tmux
On most Debian/Ubuntu systems, you can get Tmux up and running with these two commands:
sudo apt update
sudo apt install tmux
Core Tmux Concepts
Before you start using the commands, it helps to understand Tmux’s three main concepts:
-
Session: Think of this as a single Tmux process that holds all your windows. Sessions are persistent, so they keep running in the background even if you close your terminal or get disconnected.
-
Window: These are like tabs in a web browser. A session can have multiple windows, and each one can run a different task.
-
Pane: A window can be split into multiple panes, with each pane running its own independent command.
All actions are triggered by a Prefix Key, which is Ctrl + B by default. You press this prefix key, then the command key, to tell Tmux what you want to do.
Session Management
| Action | Command | What it does |
|---|---|---|
| Create a New Session | tmux new -s [session_name] | Starts a new session with a name you choose. |
| List All Sessions | tmux ls | Shows all your currently active sessions. |
| Attach to a Session | tmux attach -t [session_name] | Reconnects to a specific session. |
| Detach from a Session | Ctrl + B, then D | Disconnects from the current session without closing it. |
| Kill a Session | Inside the session, type exit or Ctrl + D | Exits and permanently closes the current session. |
Window and Pane Operations
Remember, you must hit the Prefix Key Ctrl + B before any of these commands.
| Action | Command | What it does |
|---|---|---|
| Create a New Window | C | Creates a new window in your current session. |
| List All Windows | W | Shows a list of all windows in the current session. |
| Switch Windows | N / P | Jumps to the next or previous window. |
| Select Window by Number | 0-9 | Quickly switches to a window using its number. |
| Split Pane Vertically | % | Divides the current window into two vertical panes. |
| Split Pane Horizontally | " | Divides the current window into two horizontal panes. |
| Switch Panes | Arrow Keys | Moves your cursor between different panes. |
| Kill Current Pane | X | Closes the pane you are currently in. |
Important Note: The command letters (C, W, N, P, X, etc.) are case-sensitive only in the document for clarity. When you actually use them, you should press the lowercase key (e.g., press c for C).
I hope this cheatsheet helps you work more efficiently with Tmux. Once you get these basic commands down, you’ll be able to switch between tasks and keep your work running without a hitch.