Getting started with Tmux
4 min read
This guide will go through the installation and basic usage of Tmux to get you up and running.
What is tmux?
Tmux is a terminal multiplexer an alternative to GNU Screen . In other words, it means that you can start a Tmux session and then open multiple windows inside that session. Each window occupies the entire screen and can be split into rectangular panes.
With Tmux you can easily switch between multiple programs in one terminal, detach them and reattach them to a different terminal.
Tmux sessions are persistent, which means that programs running in Tmux will continue to run even if you get disconnected.
All commands in Tmux start with a prefix, which by default is
You can easily install Tmux using the package manager of your distro.
Installing Tmux on Ubuntu and Debian
sudo apt install tmux
Installing Tmux on CentOS and Fedora
sudo yum install tmux
Installing Tmux on macOS
brew install tmux
Starting Your First Tmux Session
To start your first Tmux session, simply type
tmux in your console:
This will open a new session, create a new window, and start a shell in that window.
Once you are in Tmux you’ll notice a status line at the bottom of the screen which shows information about the current session.
You can now run your first Tmux command. For example, to get a list of all commands, you would type:
Creating Named Tmux Sessions
By default, Tmux sessions are named numerically. Named sessions are useful when you run multiple Tmux sessions. To create a new named session, run the
tmux command with the following arguments:
tmux new -s session_name
It’s always a good idea to choose a descriptive session name.
Detaching from Tmux Session
You can detach from the Tmux session and return to your normal shell by typing:
The program running in the Tmux session will continue to run after you detach from the session.
Re-attaching to Tmux Session
To attach to a session first, you need to find the name of the session. To get a list of the currently running sessions type:
The name of the session is the first column of the output.
0: 1 windows (created Sat Sep 15 09:38:43 2018) [158x35] my_named_session: 1 windows (created Sat Sep 15 10:13:11 2018) [78x35]
As you can see from the output, there are two running Tmux sessions. The first one is named
0 and the second one
For example, to attach to session
0, you would type:
tmux attach-session -t 0
Working with Tmux Windows and Panes
When you start a new Tmux session, by default, it creates a single window with a shell in it.
To create a new window with shell type
c, the first available number from the range
0...9 will be assigned to it.
A list of all windows is shown on the status line at the bottom of the screen.
Below are some most common commands for managing Tmux windows and panes:
cCreate a new window (with shell)
wChoose window from a list
0Switch to window 0 (by number )
,Rename the current window
%Split current pane horizontally into two panes
"Split current pane vertically into two panes
oGo to the next pane
;Toggle between the current and previous pane
xClose the current pane
When Tmux is started, it reads its configuration parameters from
~/.tmux.conf if the file is present.
Here is a sample
~/.tmux.conf configuration with customized status line and few additional options:
# Improve colors set -g default-terminal 'screen-256color' # Set scrollback buffer to 10000 set -g history-limit 10000 # Customize the status line set -g status-fg green set -g status-bg black
Basic Tmux Usage
Below are the most basic steps for getting started with Tmux:
- On the command prompt, type
tmux new -s my_session,
- Run the desired program.
- Use the key sequence
dto detach from the session.
- Reattach to the Tmux session by typing
tmux attach-session -t my_session.
In this tutorial, you learned how to use Tmux. Now you can start creating multiple Tmux windows in a single session, split windows by creating new panes, navigate between windows, detach and resume sessions, and personalize your Tmux instance using the
To learn more about Tmux type
man tmux in your terminal or visit the Tmux User’s Manual page.
If you have any questions or feedback, feel free to leave a comment.