Tmux Cheatsheet
This page provides a comprehensive cheatsheet for tmux, a powerful terminal multiplexer. Master essential tmux commands for efficient session, window, and pane management. This resource is designed to help developers and system administrators quickly access and utilize tmux shortcuts, enhancing productivity in the command-line environment.
Tmux Session Management Commands
Manage your tmux sessions effectively with these commands. Start new sessions, attach to existing ones, list all active sessions, and terminate them when no longer needed.
# Start a new tmux session with a specific name
tmux new -s <SESSION_NAME>
# Attach to the most recently used tmux session
tmux a
# or
tmux at
# or
tmux attach
# Attach to a specific named tmux session
tmux a -t <SESSION_NAME>
# List all active tmux sessions
tmux ls
# Kill a specific tmux session
tmux kill-session -t <SESSION_NAME>
# Kill all tmux sessions (use with caution)
tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
Tmux Window Management Shortcuts
Navigate and manage your windows within a tmux session using these keybindings. Create new windows, switch between them, rename them, and close them efficiently.
# Prefix key (default: C-b) followed by:
# Start a new window
C-b :new<CR>
# List all windows in the current session
C-b s
# Rename the current session
C-b $
# Detach from the current session (leaves it running in the background)
C-b d
# Create a new window
C-b c
# List windows with numbers and names
C-b w
# Move to the next window
C-b n
# Move to the previous window
C-b p
# Find a window by name
C-b f
# Rename the current window
C-b ,
# Kill the current window
C-b &
# Switch to a window by its number (e.g., C-b 1 for the first window)
C-b 1 ...
Tmux Pane Management Shortcuts
Split your terminal into multiple panes and manage them with these shortcuts. Create vertical and horizontal splits, swap panes, resize them, and more.
# Prefix key (default: C-b) followed by:
# Split the current pane vertically into two panes
C-b %%
# Split the current pane horizontally into two panes
C-b "
# Swap the current pane with the next pane in the chosen direction
C-b o
# Display pane numbers temporarily
C-b q
# Kill the current pane
C-b x
# Break the current pane out into its own new window
C-b +
# Restore a pane from a window (useful after breaking out)
C-b -
# Resize the current pane down by X cells
C-b :resize-pane -D <X>
# Resize the current pane up by X cells
C-b :resize-pane -U <X>
# Resize the current pane left by X cells
C-b :resize-pane -L <X>
# Resize the current pane right by X cells
C-b :resize-pane -R <X>
# Resize a specific pane (e.g., pane ID 1) to the right by X cells
C-b :resize-pane -t <PANE_ID> -R <X>
Tmux Layout and Utility Commands
Explore commands for changing pane layouts, displaying the time, and accessing the tmux help screen.
# Prefix key (default: C-b) followed by:
# Cycle through different pane layout arrangements
C-b space
# Display a large clock and the current date
C-b t
# Display the tmux command prompt
C-b :
# Display a list of all available tmux shortcuts and commands
C-b ?
Tmux is an indispensable tool for developers and system administrators who spend significant time in the terminal. By mastering these commands and shortcuts, you can dramatically improve your workflow, manage multiple tasks simultaneously, and maintain persistent sessions even when disconnected. For more in-depth information, refer to the official tmux man page and explore community resources like Stack Overflow for advanced tips and troubleshooting.