Skip to main content
This lesson covers tmux fundamentals: what tmux is, how to start it, and how to work with sessions, windows, panes, copy/paste, and basic configuration. tmux (first released in 2007) is a modern terminal multiplexer similar to GNU Screen but with several enhancements:
  • Client–server model: a single server manages multiple sessions; each session contains windows, and windows can be shared between clients.
  • Interactive menus for selecting sessions, windows, and clients.
  • The same window can be linked to multiple sessions.
  • Supports both Vim and GNU Emacs key layouts.
  • Full UTF-8 and 256-color terminal support.
A dark-themed slide titled "tmux" listing features like "Released in 2007,"
client-server model with shared windows, interactive session/window selection,
linking the same window to multiple sessions, vim and Emacs key layouts, and
UTF-8/256-color terminal support. The KodeKloud logo appears in the
top-right.
Getting started
  • Start tmux from your shell:
$ tmux
This opens a shell inside tmux and shows a status bar along the bottom of the terminal. The default command prefix (leader key) is Ctrl+b (referred to below as “prefix”). Status bar contents
  • Session name
  • Window index (tmux counts windows from 0)
  • Window name (by default tmux shows the running program name and updates it automatically)
  • An asterisk (*) indicates the currently visible window
  • Host name, time, date, etc.
Example: start tmux and create a named session and window
# Start tmux (interactive)
$ tmux

# Start tmux with a named session and named window (from shell)
$ tmux new -s "LPI" -n "Window zero"

# tmux status line (illustrative)
# [LPI] 0:Window zero*                   "debian" 19:01
# 27-Aug-19
Windows Windows are top-level workspaces inside a session. Each window can contain multiple panes. Common window operations
ActionKeys / Command
New windowprefix + c (Ctrl+b then c)
Rename current windowprefix + , (Ctrl+b then ,), type name, Enter
List windows (chooser)prefix + w (Ctrl+b then w) — navigate with arrows, Enter to select
Next windowprefix + n
Previous windowprefix + p
Jump to window Nprefix + N (e.g., prefix + 0)
Kill current windowprefix + & (confirmation asked)
Quick reference (text)
New window:        Ctrl + b, c
Rename window:     Ctrl + b, ,
List windows:      Ctrl + b, w
Next window:       Ctrl + b, n
Previous window:   Ctrl + b, p
Go to window #N:   Ctrl + b, N  (N = window number)
Kill window:       Ctrl + b, &
Panes (splitting windows) Panes are subdivisions of a window; each pane is a full pseudo-terminal. Basic pane operations
ActionKeys
Split horizontallyprefix + ” (Ctrl+b then “)
Split verticallyprefix + %
Kill current paneprefix + x (confirmation asked)
Move between panesprefix + Arrow keys
Last active paneprefix + ;
Resize by 1 lineprefix + Ctrl + Arrow
Resize by 5 linesprefix + Alt + Arrow
Swap with previous paneprefix + {
Swap with next paneprefix + }
Toggle zoom for a paneprefix + z
Show clock in paneprefix + t (quit with q)
Convert pane to its own windowprefix + !
Quick reference (text)
Split horizontally:  Ctrl + b, "
Split vertically:    Ctrl + b, %
Kill pane:           Ctrl + b, x
Move pane focus:     Ctrl + b, ARROW
Last active pane:    Ctrl + b, ;
Resize by 1 line:    Ctrl + b, Ctrl + ARROW
Resize by 5 lines:   Ctrl + b, Alt + ARROW
Swap with previous:  Ctrl + b, {
Swap with next:      Ctrl + b, }
Zoom pane:           Ctrl + b, z
Clock:               Ctrl + b, t    (quit with q)
Pane -> Window:      Ctrl + b, !
Sessions A session is a collection of windows. Sessions allow you to organize work and attach/detach clients. Session commands
ActionCommand / Keys
List sessions (chooser)prefix + s (inside tmux), OR from shell: tmux ls
Create a new session (shell)tmux new -s NAME
Create session (inside tmux)prefix + : then type new or new -s NAME
Rename sessionprefix + $
Attach to sessiontmux attach -t NAME (short: tmux a)
Detach from sessionprefix + d
Select which client to detachprefix + D
Kill a sessiontmux kill-session -t “SessionName”
Refresh client terminalprefix + r
Examples
# List sessions
$ tmux ls
LPI: 2 windows (created Tue Aug 27 19:01:49 2019) [158x39] (attached)

# Attach to a session (when only one exists)
$ tmux attach

# Kill a session from the shell
$ tmux kill-session -t "Second Session"
Be careful: killing a pane, window, or session terminates processes running inside it. Save work before confirming any kill operation.
Copy / paste and scrollback tmux provides its own copy/scrollback mode that allows selecting text, copying to an internal buffer, and pasting between panes. Steps to copy and paste
  1. Enter copy/scrollback mode: prefix + [
  2. Navigate with arrow keys, PageUp/PageDown, or vi-style keys (if configured).
  3. Start selection with Space.
  4. Move to the end of selection.
  5. Copy selection with Enter (puts it into tmux buffer).
  6. Paste into the current pane with: prefix + ]
Manage buffers from shell
# List tmux buffers
$ tmux list-buffers

# Show a buffer by index
$ tmux show-buffer -b 0

# Save a buffer to a file
$ tmux save-buffer -b 0 /tmp/tmux-buffer.txt
Configuration
  • System-wide config: /etc/tmux.conf
  • Per-user config: ~/.tmux.conf
  • Start tmux with an alternate config file: tmux -f /path/to/config
Common ~/.tmux.conf examples Change prefix to Ctrl+a and unbind default Ctrl+b:
# ~/.tmux.conf
unbind C-b
set -g prefix C-a
bind C-a send-prefix
Bind keys to select windows beyond 9 (example: Alt-0..Alt-2 → windows 10..12)
# Select window 10 with Alt-0
bind -n M-0 select-window -t :10
# Select window 11 with Alt-1
bind -n M-1 select-window -t :11
# Select window 12 with Alt-2
bind -n M-2 select-window -t :12
Note: tmux has a rich set of options and bindings — consult the manual or use the built-in command prompt (prefix + :) to explore commands.
Tip: For the complete list of commands and detailed options, read the manual: man tmux
Links and references That covers the essentials: starting tmux, working with sessions, windows, and panes, using the copy/paste buffer, and adding simple configuration. Use the tables and command summaries above as a quick reference while you practice.

Watch Video