50+ tmux cheat sheet and shortcut commands


CheatSheet


In this tutorial, we'll explore tmux, covering essential commands, session management, window and pane operations, and customization techniques to enhance your command-line efficiency.

tmux is a terminal multiplexer, an essential tool for command-line users, especially developers, system administrators, and power users. It allows for multiple terminal sessions to be created, accessed, and controlled from a single screen. tmux sessions are persistent, meaning they continue to run even when not actively connected, which is particularly useful for remote work. Inside tmux, users can split the view horizontally or vertically, creating multiple panes within a single window. This feature facilitates multitasking and enhances productivity by enabling users to monitor and manage several tasks simultaneously. With customization options, users can tailor tmux to fit their workflow, making it a versatile tool for a wide range of command-line activities.

 

1. Installing tmux

Below are the commands for installing tmux on various Linux distributions, as well as for Mac and BSD systems:

# Debian/Ubuntu
sudo apt-get install tmux

# Fedora
sudo dnf install tmux

# CentOS/RHEL
sudo yum install tmux

# Arch Linux
sudo pacman -S tmux

# openSUSE
sudo zypper install tmux

# Gentoo
sudo emerge tmux

# Slackware
sudo slackpkg install tmux

# FreeBSD
sudo pkg install tmux

# OpenBSD
sudo pkg_add tmux

# Mac (using Homebrew)
brew install tmux

 

2. Starting and Managing Sessions

Here's a table summarizing key commands for starting and managing sessions in tmux:

Action Command
Start a new session tmux or tmux new
Start a new named session tmux new -s [session-name]
List all sessions tmux ls or tmux list-sessions
Attach to the last session tmux attach or tmux a
Attach to a specific session tmux attach -t [session-name]
Detach from the current session Ctrl+b d
Rename the current session Ctrl+b $
Switch to the next session Ctrl+b )
Switch to the previous session Ctrl+b (
Kill the current session Ctrl+b &
Kill a specific session tmux kill-session -t [session-name]

This table covers the basic operations for handling tmux sessions, including creating, listing, attaching to, detaching from, and killing sessions. Remember, Ctrl+b is the default prefix key in tmux, which you press before entering any command keybindings.

 

3. Working with Windows

Here's a table with commands for managing windows in tmux:

Action Command
Create a new window Ctrl+b c
List all windows Ctrl+b w
Rename the current window Ctrl+b ,
Close the current window Ctrl+b &
Move to the next window Ctrl+b n
Move to the previous window Ctrl+b p
Move to a specific window by number Ctrl+b [0-9]
Swap current window with another Ctrl+b :swap-window -t [index]

 

4. Managing Panes

Here's a table for pane management commands in tmux:

Action Command
Split the pane horizontally Ctrl+b "
Split the pane vertically Ctrl+b %
Switch to the next pane Ctrl+b o
Rotate panes Ctrl+b Ctrl+o
Close the current pane Ctrl+b x
Toggle between panes Ctrl+b ;
Resize pane (Up, Down, Left, Right) Ctrl+b [arrow key]
Convert pane into a new window Ctrl+b !
Toggle pane layouts Ctrl+b Spacebar
Synchronize panes Ctrl+b :setw synchronize-panes

5. Advanced Features

Here's a table with advanced tmux commands for more sophisticated operations:

Feature Command
Enter copy mode Ctrl+b [
Paste from buffer Ctrl+b ]
Save buffer content to a file Ctrl+b :save-buffer [file-name]
Load buffer content from a file Ctrl+b :load-buffer [file-name]
Search in copy mode /[search-text] in copy mode
Navigate between panes in copy mode Ctrl+b [arrow keys] in copy mode
Capture pane content Ctrl+b :capture-pane
Send keys to all panes Ctrl+b :setw synchronize-panes on
Toggle mouse support Ctrl+b :set-option -g mouse on
Resize pane in larger steps `Ctrl+b :resize-pane -[L

 

6. Customizing tmux configuration

Below is a table outlining commands for customizing tmux to tailor it to your preferences:

Customization Command
Edit tmux configuration file vim ~/.tmux.conf
Reload tmux configuration Ctrl+b :source-file ~/.tmux.conf
Change prefix key set -g prefix [key] in .tmux.conf
Change status bar color set -g status-bg [color] in .tmux.conf
Set default terminal window size set -g window-size [width]x[height] in .tmux.conf
Customize pane border color set -g pane-border-style fg=[color] in .tmux.conf
Bind new key for a command bind-key [key] [command] in .tmux.conf
Change default pane layout setw -g main-pane-height [size] in .tmux.conf

 

7. Keybindings Cheat Sheet

Here's a tmux keybindings cheat sheet that provides quick references for commonly used shortcuts:

Action Keybinding
Start new session Ctrl+b c
List sessions Ctrl+b s
Detach from current session Ctrl+b d
Switch to next session Ctrl+b )
Switch to previous session Ctrl+b (
Rename current session Ctrl+b $
Split pane horizontally Ctrl+b "
Split pane vertically Ctrl+b %
Switch to next pane Ctrl+b o
Toggle last active pane Ctrl+b ;
Resize pane up/down/left/right Ctrl+b [arrow key]
Convert pane into a window Ctrl+b !
Close current pane Ctrl+b x
Enter copy mode Ctrl+b [
Paste from buffer Ctrl+b ]
Search in copy mode (backward/forward) Ctrl+b ? / /
Reload tmux configuration Ctrl+b :source-file ~/.tmux.conf

These keybindings are the default settings in tmux and can be customized in the tmux configuration file. For more detailed information and additional keybindings, the tmux manual page (man page for tmux) is a comprehensive resource.

 

Deepak Prasad

Deepak Prasad

Deepak Prasad is the founder of GoLinuxCloud, bringing over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, Networking, and Security. His extensive experience spans development, DevOps, networking, and security, ensuring robust and efficient solutions for diverse projects.

Certifications and Credentials:

  • Certified Kubernetes Application Developer (CKAD)
  • Go Developer Certification
  • Linux Foundation Certified System Administrator (LFCS)
  • Certified Ethical Hacker (CEH)
  • Python Institute PCAP (Certified Associate in Python Programming)
You can connect with him on his LinkedIn profile and join his Facebook and LinkedIn page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

1 thought on “50+ tmux cheat sheet and shortcut commands”

Leave a Comment