How AlmaBetter created an
IMPACT!Jay Abhani
Senior Web Development Instructor at almaBetter
Master Tmux with this ultimate guide on the Tmux cheat sheet! Learn essential commands and tips to boost your productivity on Ubuntu and Linux terminals today!
Tmux, short for "Terminal Multiplexer," is an indispensable tool for developers, system administrators, and anyone who spends significant time working in a terminal. Whether you're managing multiple tasks or need a robust solution for organizing your workspace, Tmux can help. This detailed Tmux cheat sheet covers essential commands, how to use Tmux on Ubuntu and Linux, and tips to streamline your workflow.
Tmux is a terminal multiplexer that allows you to run multiple terminal sessions within one window. You can split your terminal into panes, create multiple windows, switch between them, and manage them more efficiently. Tmux works well on various operating systems, including Linux, macOS, and even WSL (Windows Subsystem for Linux).
Before diving into the Tmux commands cheat sheet, let's familiarize ourselves with some essential Tmux concepts:
To start using Tmux, open your terminal and type:
tmux
This creates a new Tmux session. If you wish to create a session with a specific name, use:
tmux new-session -s session_name
Detach from session**:** You can leave the session running in the background using the command:
Ctrl+b d
This allows you to return to the normal terminal prompt without killing your session.
tmux attach-session -t session_name
Or if you have only one session running, you can simply type:
tmux attach
Now, let’s dive into some of the most common Tmux commands that you'll need to know to maximize your efficiency. Tmux uses the prefix key, which is Ctrl + b by default. This means that all commands are preceded by pressing Ctrl + b. After pressing the prefix key, you can execute the desired command.
Ctrl + b c
This creates a new window in the current session.
Ctrl + b n
Ctrl + b p
Ctrl + b <window_number>
Ctrl + b ,
Ctrl + b &
Ctrl + b w
Panes allow you to split your terminal into multiple sections. This feature is great for multitasking and running several commands in parallel.
Ctrl + b %
Ctrl + b "
Ctrl + b Left Arrow
Ctrl + b Right Arrow
Ctrl + b Up Arrow
Ctrl + b Down Arrow
Resize panes: To resize a pane, first press Ctrl + b and then hold Ctrl while pressing the arrow keys to adjust the pane size.
Ctrl + b x
Ctrl + b { or Ctrl + b }
Sessions are the heart of Tmux’s multitasking capabilities. Each session can hold multiple windows and panes.
tmux list-sessions
tmux new-session -s session_name
tmux attach -t session_name
Ctrl + b d
tmux kill-session -t session_name
Using Tmux on Ubuntu is essentially the same as using it on any other Linux distribution, but some Ubuntu-specific commands and methods are worth mentioning. If you’re running Tmux on Ubuntu, you can install it via the following command:
sudo apt-get install tmux
Once installed, you can begin using Tmux just as we described earlier. Here are some Ubuntu-specific tips for using Tmux effectively.
To start Tmux automatically whenever you open a terminal, you can add the following command to your ~/.bashrc file:
# Start tmux automatically
if which tmux >/dev/null && [ -z "$TMUX" ]; then
tmux attach-session -t main || tmux new-session -s main
fi
This will check if Tmux is installed and automatically attach to your main session when you open a terminal.
Ubuntu users often work with different environments in separate sessions. Here's how to organize your sessions:
tmux new-session -s development
tmux attach-session -t development
tmux kill-session -t development
On Linux, Tmux works similarly to how it operates on Ubuntu, since Ubuntu is a Linux distribution. Below are some Linux-specific Tmux tips and commands to boost your productivity.
Before starting, ensure Tmux is installed on your Linux machine. To check, type:
tmux -V
If Tmux is installed, this will return the version number. If not, you can install Tmux using the package manager for your Linux distribution.
sudo apt-get install tmux
sudo yum install tmux
sudo pacman -S tmux
Once installed, you can start Tmux in your terminal as mentioned earlier:
tmux
This will launch a new session. If you want to launch a session with a specific name, use:
tmux new-session -s session_name
tmux list-sessions
tmux attach-session -t session_name
Tmux is a powerful tool for anyone who works in the terminal. Whether you're using it on Ubuntu, Linux, or any other operating system, understanding how to manage sessions, windows, and panes will make you much more efficient.
By mastering the commands outlined in this Tmux cheat sheet, you’ll be able to multitask like never before and organize your terminal workflows to suit your needs. Whether you're managing server environments or running complex tasks in parallel, Tmux will be an invaluable tool in your toolkit.
More Cheat Sheets and Top Picks