In this blog, we will look at how to use the tmux utility to execute linux commands parallely on multiple terminal windows.
Install tmux
You can install tmux using the commands given below based on your OS Platform.
Platform | Install Command |
---|---|
Arch Linux | pacman -S tmux |
Debian or Ubuntu | apt install tmux |
Fedora | dnf install tmux |
RHEL or CentOS | yum install tmux |
macOS (using Homebrew) | brew install tmux |
macOS (using MacPorts) | port install tmux |
openSUSE | zypper install tmux |
Split Terminal
To split multiple tmux terminals, first execute the tmux command in the terminal.
tmux
To split the terminals vertically, press Ctrl + b
, then "
. You can create multiple terminal by executing the same.
To split the terminal horizontally, press Ctrl + b
, then %
To make all the tmux horizontal panes the same size, first press Ctrl + b, then : Next type the following
select-layout even-vertical
To make all the tmux vertical panes the same size, first press Ctrl + b, then : Next type the following
select-layout even-horizontal
And if you want to balance both width and height, you can use:
select-layout tiled
Execute Commands Prallelly
To execute command parallely on all the panes, enter the command mode using Ctrl + b
. Type :
and then paste the following
setw synchronize-panes on
Here is the demo
Conclusion
Executing commands parallely is specifically useful for DevOpe engineer working with Linux.
For instance when setting up Kubernetes cluster, you will need to configure applications on multiple terminal windows for multiple nodes.
Making use of tmux will save a lot of time in the installation process. Give it a try and we are sure you will like it.