How to use tmux on Linux?

Tmux is a terminal multiplexing utility for Unix systems that provides an interface between several programs running simultaneously on one computer. It allows users to detach from terminal sessions without killing them and reattach later, making it invaluable for remote work and long-running tasks.

Tmux operates through sessions, windows, and panes ? sessions contain multiple windows, and windows can be split into multiple panes. All commands use a prefix key (default: Ctrl-b) followed by another key.

Installation

Install tmux on Debian-based Linux systems using the apt package manager

sudo apt-get update
sudo apt-get install tmux

For Red Hat-based systems, use yum or dnf

sudo yum install tmux
# or
sudo dnf install tmux

Sessions in tmux

Sessions are the top-level containers in tmux. Each session can contain multiple windows and persists even when you disconnect from the terminal.

Creating and Managing Sessions

Start a new session

tmux
# or create a named session
tmux new-session -s gamma

Create a session with a named window

tmux new-session -s gamma -n observation

List all active sessions

tmux list-sessions
alpha: 2 windows (created Sun Jun 20 11:37:35 2021)
gamma: 1 windows (created Sun Jun 20 12:11:41 2021)

Attach to an existing session

tmux attach-session -t gamma

Rename a session

tmux rename-session -t alpha beta

Kill a session

tmux kill-session -t gamma

Essential Key Bindings

All tmux commands start with the prefix key (default Ctrl-b). Here are the most important shortcuts

Key Combination Action
Prefix + d Detach from session
Prefix + c Create new window
Prefix + w List all windows
Prefix + , Rename current window
Prefix + & Kill current window
Prefix + " Split window horizontally
Prefix + % Split window vertically
Prefix + x Kill current pane

Windows and Panes

Each tmux session contains one or more windows. Windows can be split into multiple panes, each containing its own terminal session.

Working with Panes

Split the current window horizontally

Prefix + "

Split the current window vertically

Prefix + %

Navigate between panes using Prefix + arrow keys or cycle through them with Prefix + o.

Copy Mode

Tmux has its own clipboard system for copying and pasting text between panes and sessions.

Enter copy mode

Prefix + [

Start text selection

Prefix + Space

Copy selected text to tmux clipboard

Enter

Paste from tmux clipboard

Prefix + ]

Use arrow keys to navigate and position the cursor during text selection. Press Escape to exit copy mode without copying.

Conclusion

Tmux is a powerful terminal multiplexer that enables efficient multitasking through sessions, windows, and panes. Its session persistence feature makes it essential for remote development work. Mastering the basic key bindings and understanding the hierarchy of sessions ? windows ? panes will significantly improve your command-line productivity.

Updated on: 2026-03-17T09:01:38+05:30

618 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements