How to Execute Linux Commands Parallely in Multiple Terminals

linux tmux

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.

PlatformInstall Command
Arch Linuxpacman -S tmux
Debian or Ubuntuapt install tmux
Fedoradnf install tmux
RHEL or CentOSyum install tmux
macOS (using Homebrew)brew install tmux
macOS (using MacPorts)port install tmux
openSUSEzypper 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

Execute Linux Commands Parallely in Multiple Terminals

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.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *