TMUX Parallel Command Execution

Sometimes you need to execute identical commands on multiple server. For example if you are installing members of a cluster. TMUX offers a possibility to send all your commands to multiple terminal-sessions.

I will use the default leader-key ctrl + b in this article. If you have remapped it, change the commands accordingly.

Step 1: Prepare your Panes

Begin by arranging the panes and connect to the target servers.

# vertical split
ctrl+b %

# horizontal split
ctrl+b "

Step 2: Activate Parallel Execution

Now you can activate the Parallel Execution

ctrl+b :setw synchronize-panes on

Now every keystroke gets send to all panes. That even includes Vim-Commands.

A word of Warning!

Be carefull using the Bash-History. If you use the up arrow to get the last commands you have no garantee that all servers will have the same commands in thier history.
This can lead to unexpected results…

Step 3: Deactivate Parallel Execution

Once you are done with you parallel work remember to disable the parallel-execution.

ctrl+b :setw synchronize-panes off
profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.