tmux Command in Linux: Sessions, Windows, and Panes

Tmux is a terminal multiplexer, an alternative to GNU Screen . It allows you to start a session and open multiple windows inside it. Each window occupies the entire screen and can be split into rectangular panes.
With Tmux, you can easily switch between multiple programs in one terminal, detach them, and reattach them to a different terminal. Tmux sessions are persistent, which means that programs running in Tmux will continue to run even if you get disconnected.
All commands in Tmux start with a prefix, which by default is Ctrl+b.
This guide covers the installation and usage of Tmux to get you up and running.
Syntax
The basic tmux command syntax is:
tmux [OPTIONS] [COMMAND [FLAGS]]Run tmux without a command to start a new session. Use subcommands such as new, attach, ls, or kill-session when you want to manage sessions from the shell.
Installing Tmux
You can install Tmux using the package manager of your distribution.
Ubuntu and Debian
sudo apt install tmuxFedora, RHEL, and Derivatives
sudo dnf install tmuxmacOS
brew install tmuxCreating a New Tmux Session
To start a new session, run tmux in your terminal:
tmuxThis opens a new session, creates a window inside it, and starts a shell. You will see a status line at the bottom of the screen showing the session name and window list.
By default, sessions are named with a number starting from 0. To create a session with a descriptive name, use the -s flag:
tmux new -s workNamed sessions are easier to manage when you have several running at the same time. You can also start a session in the background without attaching to it by adding the -d flag:
tmux new -s backup -dThis is useful when you want to launch a long-running process inside tmux from a script or another session.
To see all available key bindings at any time, press Ctrl+b ?.
Detaching from a Session
You can detach from the Tmux session and return to your normal shell by typing:
Ctrl+b d
The programs running in the Tmux session will continue to run after you detach.
Reattaching to a Session
To attach to a session, you first need to find its name. To get a list of currently running sessions, type:
tmux lsThe name of the session is the first column of the output:
0: 1 windows (created Thu Jan 30 09:38:43 2026) [158x35]
my_session: 1 windows (created Thu Jan 30 10:13:11 2026) [78x35]There are two running sessions. The first one is named 0 and the second one my_session.
To attach to session 0, type:
tmux attach-session -t 0To attach to the most recently used session, you can simply run:
tmux attachSwitching Between Sessions
When you have multiple sessions running, you can switch between them without detaching first.
Press Ctrl+b s to open an interactive session list. Use the arrow keys to pick a session and press Enter to switch to it.
You can also switch from the command line inside tmux by pressing Ctrl+b : and typing:
switch -t workTo cycle through sessions quickly:
Ctrl+b(— Switch to the previous sessionCtrl+b)— Switch to the next session
Working with Windows
When you start a new Tmux session, it creates a single window with a shell in it.
To create a new window, type Ctrl+b c. Windows are numbered starting from 0. A list of all windows is shown on the status line at the bottom of the screen.
The following key bindings are used for managing windows:
Ctrl+bc— Create a new windowCtrl+bw— Choose a window from a listCtrl+b0— Switch to window 0 (by number)Ctrl+bn— Switch to the next windowCtrl+bp— Switch to the previous windowCtrl+b,— Rename the current windowCtrl+b&— Close the current window
Working with Panes
Tmux allows you to split a window into multiple panes. Each pane runs its own shell.
The following key bindings are used for managing panes:
Ctrl+b%— Split the current pane vertically (left and right)Ctrl+b"— Split the current pane horizontally (top and bottom)Ctrl+bo— Go to the next paneCtrl+b;— Toggle between the current and previous paneCtrl+bArrow keys— Move to the pane in the given directionCtrl+bCtrl+Arrow keys— Resize the current paneCtrl+bSpace— Cycle through pane layoutsCtrl+bz— Toggle pane zoom (fullscreen)Ctrl+bx— Close the current pane
Copy Mode
Tmux has a copy mode that allows you to scroll through the terminal output and copy text. To enter copy mode, type:
Ctrl+b [
You can then use the arrow keys or Page Up / Page Down to scroll. Press q to exit copy mode.
To copy text in copy mode:
- Press
Spaceto start selecting text. - Move the cursor to highlight the text you want to copy.
- Press
Enterto copy the selected text. - Press
Ctrl+b]to paste the copied text.
Killing Sessions
To kill a specific Tmux session, use:
tmux kill-session -t session_nameTo kill all sessions except the current one:
tmux kill-session -aTo kill the Tmux server and all sessions:
tmux kill-serverCustomizing Tmux
When Tmux is started, it reads its configuration from ~/.tmux.conf if the file is present.
Here is a sample ~/.tmux.conf configuration with a few useful options:
# Improve colors
set -g default-terminal 'tmux-256color'
# Set scrollback buffer to 10000
set -g history-limit 10000
# Enable mouse support
set -g mouse on
# Customize the status line
set -g status-style 'fg=green,bg=black'To reload the configuration without restarting Tmux:
tmux source-file ~/.tmux.confOr from within Tmux, type Ctrl+b : and enter:
source-file ~/.tmux.conf
Tmux Commands Quick Reference
For a printable quick reference, see the Tmux cheatsheet .
| Action | Key / Command |
|---|---|
| New session | tmux new -s name |
| New session (detached) | tmux new -s name -d |
| List sessions | tmux ls |
| Attach to session | tmux attach-session -t name |
| Switch session | Ctrl+b s |
| Detach | Ctrl+b d |
| New window | Ctrl+b c |
| Next window | Ctrl+b n |
| Split vertically | Ctrl+b % |
| Split horizontally | Ctrl+b " |
| Navigate panes | Ctrl+b Arrow keys |
| Cycle pane layouts | Ctrl+b Space |
| Zoom pane | Ctrl+b z |
| Close pane | Ctrl+b x |
| Copy mode | Ctrl+b [ |
| Paste | Ctrl+b ] |
| Kill session | tmux kill-session -t name |
| Reload config | tmux source-file ~/.tmux.conf |
FAQ
What is the difference between Tmux and GNU Screen?
Both are terminal multiplexers, but Tmux has a more modern codebase, better pane management, a scriptable command interface, and more active development. Screen is still widely available but receives fewer updates.
How do I scroll in Tmux?
Press Ctrl+b [ to enter copy mode, then use the arrow keys or Page Up / Page Down to scroll. Press q to exit copy mode. Alternatively, enable mouse support with set -g mouse on in your ~/.tmux.conf to scroll with the mouse wheel.
How do I change the prefix key?
Add the following to your ~/.tmux.conf to change the prefix from Ctrl+b to Ctrl+a:
set -g prefix C-a and unbind C-b.
Can I use the mouse in Tmux?
Yes. Add set -g mouse on to your ~/.tmux.conf. This enables mouse-based pane selection, window switching, pane resizing, and scrolling.
How do I rename a session?
From within Tmux, press Ctrl+b $ and type the new name. From the command line, use tmux rename-session -t old_name new_name.
Conclusion
The tmux command gives you persistent sessions that survive disconnects, split panes for side-by-side work, and named windows to keep projects organized. For the full option list, run man tmux or see the tmux User’s Manual
.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page