We’ll show you how to install and configure tmux. In this post, we will write about tmux, which is a terminal multiplexer, a lot like GNU Screen but much more powerful. If you spend a lot of time in a CLI, then you’ll love tmux.
Table of Contents
1. What is tmux?
According to the tmux authors:
tmux is a terminal multiplexer. What is a terminal multiplexer? It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more.
2. tmux installation
Installation is pretty straightforward if you have Ubuntu or any other Debian-based distribution you can install tmux with:
sudo apt-get install tmux
yum install tmux
and on MacOS:
brew install tmux
After installation, to start tmux run
tmux in your terminal window.
3. tmux Configuration & Prefix key
The global configuration file is located at
/etc/tmux.conf and the user specific configuration file is located at
~/.tmux.conf. The default prefix is
Ctrl-b but if you want to change it to
Ctrl-a (GNU Screen’s default prefix), you need to add the following code to your ~/.tmux.conf file:
unbind C-b set -g prefix C-a bind C-a send-prefix
4. tmux Session Management
tmux is developed on a client-server model which means that the session is stored on the server and persist beyond ssh logout.
The following command will create a new session called mysession:
tmux new-session -s mysession
To attach to a session run:
tmux attach -t mysession
To list all session run:
You can kill a session using the following command:
Now just $43 .99
tmux kill-session -t mysession
Frequently used sessions commands
Ctrl-b d Detach from the current session Ctrl-b ( Go to previous session Ctrl-b ) Go to next session Ctrl-b L Go to previously used session Ctrl-b s Choose a session from the sessions list
5. tmux Windows (tabs) Management
Each session can have multiple windows. By default all windows are numbered starting from zero.
Frequently used windows (tabs) commands
Ctrl-b 1 Switch to window 1 Ctrl-b c Create new window Ctrl-b w List all windows Ctrl-b n Go to next window Ctrl-b p Go to previous window Ctrl-b f Find window Ctrl-b , Name window Ctrl-b w Choose a window from the windows list Ctrl-b & Kill the current window
6. tmux Panes Management
With tmux, you can split windows into multiple panes.
Frequently used panes commands
Ctrl-b "Split the pane vertically (top/bottom) Ctrl-b %Split the pane horizontally (left/right) Ctrl-b qShow pane numbers Ctrl-b xKill the current pane Ctrl-b +Break pane into window Ctrl-b -Restore pane from window Ctrl-b leftGo to the next pane on the left Ctrl-b right Go to the next pane on the right Ctrl-b upGo to the next pane on the top Ctrl-b downGo to the next pane on the bottom Ctrl-b o Cycle through all panes Ctrl-b ; Go to previously used pane
If you use one of our VPS hosting services, do not hesitate to ask our expert Linux admins if you need help getting started with Tmux. They are available 24×7 and will take care Installation and configuration of tmux immediately.
PS. If you liked this post, on how to Install and configure tmux, please share it with your friends on the social networks using the buttons below or simply leave a comment in the comments section. Thanks.
4 thoughts on “Install and configure tmux”
One of my favorite things about tmux is how easy it is to resize panes:
C-b, followed by holding down Alt, and using the arrow keys to resize
Can someone explain how they use sessions and windows and panes?
It feels like one too many levels, why both sessions AND windows?
I’m willing to believe there is a use case, but for the life of me I can’t come up with one.
Please read the tmux man page for more information on this.
I use sessions for different projects, and windows and panes within a project. For example, I’ll have a session for my puppet code, and a session for a bash script I’m working on. Within the puppet session, if I’m going to work on a new module, I open a new window. If I’m writing code in vim, I usually split off a pane so I can test running it next to it. Having the error output next to the code makes debugging really fast.
In a lot of ways, it basically acts like a tiling window manager for the terminal. The advantage over a window manager is that the whole layout can be accessed remotely. So if I’m working on a project from work, I can quickly resume working on the project from my home computer after SSH’ing in and reattaching to the tmux session.