Terminal Multiplexing with TMux in Linux
As Linux users, most of our time is spent working in the terminal window, and it's no surprise that we often require multiple terminals for multitasking. Thus the invention of multiplexers. Which significantly enhanced the functionality of the terminal, leading to increased productivity.
There are multiple terminal multiplexers but one of the most popular is TMux. In this article, we will deep dive into TMux's key features.
TMux is a command-line utility for Unix-like operating systems, including Linux. It enables users to create and manage multiple terminal sessions within a single window. In simple words, it's an alternative to using the graphical tabs and lets us organize our terminal into panes and windows.
Installing TMux in Linux
we can install tmux with our package manager (in the terminal)
Debian/Ubuntu:
sudo apt-get install tmuxRedhat
sudo yum install tmuxFedora
sudo dnf -y install tmux
Starting Tmux inside Terminal
After installing tmux, you can simply start it by typing the command tmux in our terminal. This initiates a new tmux session.
tmuxPanes in Tmux
Similar to Vim, tmux also has a leader key that is used to trigger various commands within tmux., by default its ctrl + b
To split the window vertically, we can use
ctrl + b %To split the window horizontally, we can use
ctrl + b "Similarly to closing a window, we can use
Ctrl + b x, and to Navigate between the panes we can useCtrl + b <arrow-key>For changing the panel layout leader key with space can be used
Ctrl + b spaceTo resize a panel in tmux, we can use the
resize-panecommand. Press the leader key to enter command mode. Similar to Vim, we can then enter the resize command to adjust the size of the pane using:symbol.Ctrl + b : resize-pane -L 10 Ctrl + b : resize-pane -R 10 Ctrl + b : resize-pane -D 10 Ctrl + b : resize-pane -U 10
Windows in Tmux
windows in tmux is a little different from Panes, while panes divide the terminal, on the other hand, windows can be used as a new tab. Where each window can contain one or more panes.
To create a new window, press the leader key and
cthat isctrl + b cTo Navigate to the next window,
Ctrl + b ncan be usedTo Navigate to the previous window,
ctrl + b pcan be used&is used to close a window,ctrl + b &
Renaming windows
Now that we have multiple windows within our terminal emulator, it's a good idea to rename it to streamline our workflow. For Renaming we can use , with ctrl + b
List Windows
We can see a list of windows by using Ctrl-b followed by w. This provides a visual overview, where we can navigate to a window using the arrow keys.
Sessions in Tmux
Sessions in Tmux provide an easy way to group tasks or activities in a single terminal multiplexer in one or more instances.
Creating a Session
As soon as we open tmux in the terminal, a default session is created. However, we can also create a new session with a different name.
For naming a session, we can use the new-session command.
tmux new-session -s session_nameDetaching from a Session
One session is created, and once inside, we can detach it using the combination of d after the leader key. ctrl + b d
Attaching to a Session
After detaching, we can log back in by attaching it using the attach-session command.
tmux attach-session -t session_nameConnect with me on LinkedIn:
Feel free to connect with me on LinkedIn to stay updated on the latest trends in #backend development, #Linux, and #scripting. Let's build a stronger network together!






