Learn how to install and basic usage of Tmux on your Linux system in this step-by-step tutorial.
What is tmux?
Tmux is a highly efficient terminal multiplexer, offering an alternative to GNU Screen. With Tmux, you can create multiple windows within a single session and effortlessly switch between different programs. It allows you to create multiple windows within a session, each of which can be split into rectangular panes.
With Tmux, you can effortlessly switch between multiple programs in one terminal, detach, and reattach them to different terminals. One of the most significant advantages of Tmux is that its sessions are persistent, ensuring that programs running within Tmux will continue to run even if you get disconnected.
All Tmux commands start with a prefix, which is
ctrl+b by default.
How to Install Tmux on Linux
You can use the package manager of your distro to install tmux on Linux easily. Here you can follow the commands to install tmux on a different operating system.
How to Install Tmux on Ubuntu and Debian
On both Ubuntu and Debian, you can install tmux by running the following command:
sudo apt install tmux
How to Install Tmux on CentOS and Fedora
Run the following command to install tmux on CentOS and Fedora:
sudo yum install tmux
How to Install Tmux on macOS
Tmux can be also installed and used on macOS just Linux. Use the following command to install tmux on macOS:
brew install tmux
How to Start Tmux Session
By simply typing
tmux in your console and hit enter. This will initiate a screen session, which will generate a fresh window and launch a shell within that window.
Upon entering Tmux, a status line will appear at the base of your display screen, providing you with details about your current session. Now you’re ready to run your first Tmux command, To access the list of all commands type:
How to Create Named Tmux Sessions
Tmux sessions are usually numbered by default, but creating named sessions can be advantageous when you manage multiple tmux sessions simultaneously. To make a new named session, use the tmux command and specify the following arguments:
tmux new -s session_name
When choosing a session name, it’s recommended to select a descriptive one that accurately reflects its purpose. Improve your productivity with Tmux by creating organized named sessions.
How to Detach from Tmux Session
To detach from the scene session simply type
Ctrl+b d and the program running in the screen session will continue to run after you detach from the session.
How to Reattach to a Tmux Session
If you want to re-attach to a Tmux session, you’ll need to know the name of the session first. To see a list of currently running sessions, use the command:
The first column of the output will show you the name of the session.
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]
From the output, there are two sessions running, the first one is named
0 and the second one is named
To attach to session 0, enter the command:
tmux attach-session -t 0
How to Work with Tmux Windows and Panes
when you initiate a tmuix session, it will create a single window containing a shell by default. To add a new window with a shell, simply use the command
Ctrl+b c . Tmux will automatically assign the first available number from the range 0…9 to the new window.
Here are some popular commands for managing Tmux windows and panes:
cCreate a new window with a shell
- Ctrl+b w Choose a window from a list
0Switch to window 0 by number
,Rename the current window
%Split the current pane horizontally into two panes
"Split the current pane vertically into two panes
oGo to the next pane
;Toggle between the current and previous pane
xClose the current pane
How to customize Tmux
Tmux reads its configuration parameters from the
~/.tmux.conf file if available when it is initiated.
Check out this sample ~/.tmux.conf configuration with a customized status line and additional options to customize your Tmux experience:
~/.tmux.conf # 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
Basics of Tmux
To begin using the tmux, follow these fundamental steps:
- Open the command prompt and enter
tmux new -s my_session
- Launch your desired program.
- To detach from the session, use the key combination
Ctrl-b + d
- To rejoin the Tmux session, enter
tmux attach-session -t my_session
By following these steps, you can easily start using Tmux and managing your terminal sessions with efficiency.
In this Tmux tutorial, you learned about how to efficiently manage your terminal sessions. By following these easy steps, you will be able to create multiple Tmux windows within a single session, divide them into new panes, and navigate seamlessly between them. Additionally, you’ll learn how to detach and resume sessions and customize your Tmux instance by editing the
If you need further information on Tmux, type
man tmux in your terminal or check out the Tmux User’s Manual page.
Don’t hesitate to leave a comment if you have any questions or feedback.