Tmux Cheat Sheet: Essential Commands And Quick References (2024)

Running parallel processes on a graphical user interface (GUI) usually requires tabbed terminals. But what if you could only work with command-line interfaces (CLI)? The answer is Tmux, which is short for “terminal multiplexer.”

Better still, in Tmux, you can detach from a session without losing its state and later return to it by re-attaching it. This hands-free functionality is helpful when you, say, need to make multiple SSH connections because, by default, an SSH session occupies the entire CLI, hindering you from working on other tasks in tandem.

A PDF download of this cheat sheet is available here.

Tmux Cheat Sheet Search

Search our Tmux cheat sheet to find the right cheat for the term you're looking for. Simply enter the term in the search bar and you'll receive the matching cheats available.

Table Of Contents

  1. Tmux Cheat Sheet Search
  2. Install Tmux
  3. Tmux Commands
  4. Tmux Shortcuts
  5. Tmux Sessions
  6. Tmux Windows
  7. Tmux Command Generator
  8. Tmux Panes
  9. Tmux Copy Mode
  10. Tmux Configuration
  11. Frequently Asked Questions

Install Tmux

Tmux is available for Linux and macOS. As for Windows, you can run Tmux via the Linux Subsystem feature by following the procedures here if you’re using Windows 10 build 14361 or above. This article assumes you are using either Linux or macOS.

CommandDescription
# Homebrew
brew install tmux
Install on macOS
# Ubuntu / Debian *
sudo apt-get update
sudo apt-get install tmux
# Fedora
sudo
dnf -y install tmux
# CentOS
sudo
yum -y install tmux
Install on Linux
(*Depending on Linux distribution, you may need to replace apt-get with apt.)

Tmux Terms

Familiarize yourself with them as they often appear in Tmux-related discussions.

TermDescription
PaneAn open command prompt (known as “pseudo-terminal”), which may occupy the entire screen or appear horizontally/vertically stacked
WindowA single/split view of open panes occupying the screen:

SessionA single collection of pseudo-terminals under the management of Tmux. Once you kill the last session, Tmux exits. Each session is persistent and will survive accidental disconnection (such as SSH connection timeout) or intentional detaching by the user.
In the example above, the session comprises panes 0:bash, 1:bash, and 2:bash. The current pane is 2:bash, marked by an asterisk *. Here, the cursor is active, and you can type into the pane. The other pane in the same window is 1:bash, marked by a hyphen -.
ClientThe background process displaying your session
ServerA single server manages all open sessions. Servers and clients are separate processes that communicate through a socket in /tmp.

Tmux Commands

You may run Tmux commands by name from the CLI, such as tmux starts a new session. When you start Tmux, it creates a new single-window session and displays it on the screen.

A status line at the bottom shows current session information and is used to enter interactive commands prefixed by the trigger key combination Ctrl+b (Linux) or control+b (macOS). This trigger tells Tmux to watch out for keystrokes of interest.

Ctrl+b alone applies to short commands of one or two keys. Ctrl+b followed by the colon character (:) brings up a prompt for you to issue specific commands, after which you press Enter for execution.

Other Links You Might Like:

  • Linux File Permissions Cheat Sheet
  • Linux Command Line Cheat Sheet
  • Unix Commands Cheat Sheet
  • Tcpdump Cheat Sheet
  • Bash Cheat Sheet
  • Vi Cheat Sheet
  • Our Linux Courses Collection

Tmux Shortcuts

Run the following from the CLI:

CommandDescription
tmuxLaunch Tmux
tmux -VCheck Tmux version
tmux list-keys | lessList all commands
tmux lsShow all sessions
tmux infoShow every session, window, and pane
tmux a(Re)attach to the most recently created session
man tmuxDisplay full manual of Tmux

Run these commands inside a Tmux session:

CommandDescription
qAfter execution of a command yields a display, close the display. For example, Ctrl+b+? brings up a list, and a single q keypress closes the list.
Ctrl+b
<command>
Send <command> to Tmux instead of shell CLI. For each of the following items, replace <command> with the given key.
Ctrl+lClear console contents (the “l” is “L” in small caps)
General
<command>
?
:list-keys
List all commands
:Enter command mode (display prompt for detailed Tmux commands)
tShow computer time
Windows
<command>
cCreate new window
,Rename current window
pNavigate to previous window
nNavigate to next window
wList windows (which you may select and expand / collapse with arrow keys)
Panes
<command>
%Split vertically
"Split horizontally
(right arrow key)Switch to right pane
(left arrow key)Switch to left pane
(up arrow key)Switch to upper pane
(down arrow key)Switch to lower pane
Sessions
<command>
dDetach from session

Scroll down for specific commands in detail.

Tmux Sessions

Create new session

CommandDescription
tmux
tmux new
tmux new-session
Create new session from CLI
Ctrl+b :newCreate new session from inside Tmux
tmux new -s sess0Create new session named sess0
Ctrl+b :new sess0Create new session sess0 from inside Tmux

List all sessions

CommandDescription
tmux ls
tmux list-sessions
Show all sessions
Ctrl+b sShow all sessions from inside Tmux

Operations on sessions

CommandDescription
tmux a
tmux at
tmux attach
tmux attach-session
Attach to the most recently created session
tmux a -t s0Attach to session s0
Ctrl+b <command>
$Rename session
dDetach from session
wSession and window preview
(Move to previous session
)Move to next session

Terminate (kill) sessions

CommandDescription
tmux kill-ses
tmux kill-session
Kill last active session
tmux kill-ses -t s0Kill session named s0
tmux kill-ses -aKill all sessions except the current one
tmux kill-ses -a -t s0Kill all sessions except s0

OTHER CHEAT SHEETS YOU MAY LIKE:

  • Linux File Permissions Cheat Sheet
  • Linux Command Line Cheat Sheet
  • Bash Cheat Sheet

Tmux Windows

CommandDescription
tmux new -s s1 -n w2Create new session s1 and window w2
Ctrl+b <command>
cCreate new window
,Rename active window
&Close active window (Tmux may prompt you to confirm your action with y/n)
pNavigate to previous window
nNavigate to next window
wList windows (which you may select and expand / collapse with arrow keys)
:swapw -s 0 -t 2Swap windows 0 and 2(swapw is short for swap-window)
:swapw -t -1Move active window to the left by one position

Tmux Command Generator

Say goodbye to the hassle of trying to remember the exact syntax for your Tmux commands! With our Tmux Command Generator, you can simply say what you need Tmux to do, and we will generate the command for you.

Tmux Panes

CommandDescription
Ctrl+b <command>
qShow pane numbers:

q 0 … 9Switch to pane by number
oGo to next pane
zZoom in/out of pane
!Convert pane into new window
%Split vertically
"Split horizontally
Switch to right pane
Switch to left pane
Switch to upper pane
Switch to lower pane
;Toggle last active pane
[spacebar]Toggle between pane layouts
{Move current pane leftward
}Move current pane rightward
xClose current pane
:setw synchronize-panesToggle synchronize-panes (the ability to send the same command to all panes at once)

:resize-pane -L 5Move the boundary of the pane leftwards by 5 lines.
Direction flags:
-U upwards
-D downwards
-L leftwards
-R rightwards
M #
M: meta key; ALT for Linux, ESC for macOS#: 1, 2, 3, 4, 5
Splitting panes in a designated form:
#=1: uniform vertical split
#=2: uniform horizontal split
#=3: horizontal split, main pane on top, others on bottom, vertically split, all same width
#=4: vertical split, main pane left, others right, horizontally split, all same height
#=5: tile, new panes on bottom, same height before same width

Tmux Copy Mode

You can copy and paste text content in Tmux under Copy Mode. The buffer in Tmux is its clipboard and buffer_0, buffer_1, etc. correspond to clipboard items copied from a Tmux session.

CommandDescription
Ctrl+b :setw -g mode-keys viUse vi keys in the buffer (vi: vim editor)
Ctrl+b [Enter copy mode
Scroll up
Scroll down
qQuit copy mode
0Go to beginning of line
$Go to end of line
gGo to first line
GGo to last line
hMove cursor left
jMove cursor down
kMove cursor up
lMove cursor right
bTraverse text content backward, cursor on first character of each word
eTraverse text content forward, cursor on last character of each word
wTraverse text content one word at a time
/Search forward
?Search backward
nNext keyword occurrence
NPrevious keyword occurrence
[Spacebar]Begin selection
[Enter]Copy selection
ESCClear selection
Ctrl+b ]Paste selection
Ctrl+b :show-bufferDisplay buffer_0 contents
Ctrl+b :capture-paneCopy whole visible contents of the pane to a buffer
Ctrl+b :list-buffersShow all buffers
Ctrl+b :choose-bufferShow all buffers and paste selected
Ctrl+b :save-buffer buf.txtSave buffer contents to buf.txt
Ctrl+b :delete-buffer -b 1Delete buffer_1

Tmux Configuration

You can configure Tmux via the ~/.tmux.conf file. If it doesn’t exist, create it:

$ touch ~/.tmux.conf

To reload Tmux with the new settings:

$ tmux source-file ~/.tmux.conf

Custom Keystrokes

Add these commands to ~/.tmux.conf to modify Tmux function keys. Each command spans two lines. The unbind command deactivates the default key combination.

CommandDescription
unbind '"'
bind - split-window -v
Change key combination to split window into two horizontal panes: Replace default Ctrl+b " with Ctrl+b – (hyphen)
unbind %
bind | split-window -h
Change key combination to split window into two vertical panes: Replace default Ctrl+b % with Ctrl+b | (pipe)
unbind C-b
set -g prefix C-a
Replace trigger key combination Ctrl+b with Ctrl+a

Making Tmux Copy Mode to default to vi keys

CommandDescription
setw -g mode-keys viUse vi keys in the buffer

Customization

The following commands are for customizing the status bar at the bottom of a Tmux window:

CommandDescription
set -g status-justify [left|centre|right]Aligns the names of Tmux windows left/center/right
set -g status-left '...'Replaces name of current session with ‘...’ in status bar
setw -g
window-status-format
`#[fg=white,bg=black]#I`
Formats the window names as follows:

Default window formatting:

Variables:
#I: window index
#S: session name
#W: window name

For detailed formatting instructions: man tmux > /STYLES > keep pressing “n” key until you reach the section titled “STYLES”.

Tmux Cheat Sheet: Essential Commands And Quick References (6)

To reset Tmux to default settings, delete all lines in ~/.tmux.conf and run tmux kill-server. Close any running CLI terminals, reopen the terminal and start Tmux again.

Frequently Asked Questions

What is Tmux?

Tmux, short for “terminal multiplexer,” is a command-line program similar to having multiple terminal tabs open in a GUI. Unlike a GUI, where navigating away from a tab may interrupt a running process, operations continue running in the background even after you detach the sessions involved.

How do you enter commands in Tmux?

You can enter commands either via the CLI prefixed by tmux, or by entering a Tmux session and prefixing your commands with the trigger Ctrl+b for short commands, and Ctrl+b+: (colon) for long commands.

How do I create a Tmux session?

Command: tmux new
Details: Refer to Create new session.

How do I list all Tmux sessions?

Command: tmux ls
Details: Refer to List all sessions.

How do I switch tabs in Tmux?

In a Tmux session, Ctrl+b p or Ctrl+b n
Details: This is the same as navigating between windows in Tmux. Refer to Tmux Windows.

How do I use Tmux with SSH?

1. Start a new session containing a window for each SSH instance.
2. Execute an SSH command in each window.
3. When you’re ready, detach from the session.
With the SSH session in the background, you may use the CLI shell for other purposes.

Why is Tmux useful?

Tmux can help users:
- Do parallel processing, such as multiple SSH instances, web scraping, real-time data analysis, and debugging
- Monitor resource allocation and load balancing.

How can I download the Tmux cheat sheet PDF?

You may download it here.

Level Up in Cyber Security: Join Our Membership Today!

Tmux Cheat Sheet: Essential Commands And Quick References (7)
Tmux Cheat Sheet: Essential Commands And Quick References (8)

MEMBERSHIP

  • Tmux Cheat Sheet: Essential Commands And Quick References (9)

    Cassandra Lee

    Cassandra is a writer, artist, musician, and technologist who makes connections across disciplines: cyber security, writing/journalism, art/design, music, mathematics, technology, education, psychology, and more. She's been a vocal advocate for girls and women in STEM since the 2010s, having written for Huffington Post, International Mathematical Olympiad 2016, and Ada Lovelace Day, and she's honored to join StationX. You can find Cassandra on LinkedIn and Linktree.

Tmux Cheat Sheet: Essential Commands And Quick References (2024)
Top Articles
Malware analysis BootstrapperV1.17.exe Malicious activity | ANY.RUN - Malware Sandbox Online
Chilangos Mexican Pizzas
Design215 Word Pattern Finder
Wellcare Dual Align 129 (HMO D-SNP) - Hearing Aid Benefits | FreeHearingTest.org
Costco in Hawthorne (14501 Hindry Ave)
Blue Ridge Now Mugshots Hendersonville Nc
Facebook Marketplace Charlottesville
More Apt To Complain Crossword
What is the difference between a T-bill and a T note?
Diablo 3 Metascore
What is Cyber Big Game Hunting? - CrowdStrike
Cvb Location Code Lookup
Craftology East Peoria Il
Google Flights Missoula
Vistatech Quadcopter Drone With Camera Reviews
Erica Banks Net Worth | Boyfriend
Halo Worth Animal Jam
Decosmo Industrial Auctions
Timeforce Choctaw
Yog-Sothoth
Wisconsin Volleyball Team Boobs Uncensored
Sec Baseball Tournament Score
Lacey Costco Gas Price
No Limit Telegram Channel
How do you get noble pursuit?
Ihs Hockey Systems
Miller Plonka Obituaries
Gncc Live Timing And Scoring
Productos para el Cuidado del Cabello Después de un Alisado: Tips y Consejos
Housing Assistance Rental Assistance Program RAP
MethStreams Live | BoxingStreams
Skroch Funeral Home
Amici Pizza Los Alamitos
Arcane Odyssey Stat Reset Potion
Kips Sunshine Kwik Lube
Blue Beetle Movie Tickets and Showtimes Near Me | Regal
Obsidian Guard's Skullsplitter
Afspraak inzien
The best Verizon phones for 2024
How to Draw a Sailboat: 7 Steps (with Pictures) - wikiHow
How to play Yahoo Fantasy Football | Yahoo Help - SLN24152
Dinar Detectives Cracking the Code of the Iraqi Dinar Market
Mudfin Village Wow
Arigreyfr
ACTUALIZACIÓN #8.1.0 DE BATTLEFIELD 2042
Tableaux, mobilier et objets d'art
Exploring the Digital Marketplace: A Guide to Craigslist Miami
Yosemite Sam Hood Ornament
antelope valley for sale "lancaster ca" - craigslist
Mawal Gameroom Download
Hkx File Compatibility Check Skyrim/Sse
Festival Gas Rewards Log In
Latest Posts
Article information

Author: Kerri Lueilwitz

Last Updated:

Views: 5584

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Kerri Lueilwitz

Birthday: 1992-10-31

Address: Suite 878 3699 Chantelle Roads, Colebury, NC 68599

Phone: +6111989609516

Job: Chief Farming Manager

Hobby: Mycology, Stone skipping, Dowsing, Whittling, Taxidermy, Sand art, Roller skating

Introduction: My name is Kerri Lueilwitz, I am a courageous, gentle, quaint, thankful, outstanding, brave, vast person who loves writing and wants to share my knowledge and understanding with you.