Have you ever needed to run the same command, on multiple servers? I've used cssh and pssh with great success in the past but tmux incorporates the parallelism features, including the features of another old school tool, screen.
I use this tool when teaching RH436L Red Hat High Availability Clustering, as we have to run the same commands on various nodes without using ansible.
Let's install tmux:
yum install -y tmux
Let's run tmux now:
You should see your terminal window with a horizontal green bar at the bottom:
All tmux commands begin with the prefix ^b (control b) so enter the prefix following by.a command:
I need to monitor the output of top of 4 servers, node[abcd] and look at the output in a single window so what I'm going to do is take my current window and split it horizontally using the command ^b "
We call these elements "panes". Note that my cursor is in the bottom pane.
Now I want to take the pane where my cursor is, and split it vertically using the command ^ b %
My cursor is automatically positioned to be in the bottom right pane.
Next, we want to move the cursor to the top pane, and then split that vertically. To move your cursor around the panes use ^ b o and then use ^ b % to split the top pane vertically.
Now I can use ^ b o to move my cursor around the various panes, and ssh into the nodes I want to run commands on.
To synchronize the commands from one pane, to all the other panes use ^ b :setw synchronize-panes on
You will see the command at the bottom left corner of your tmux window.
Now run your command, I've run top, and it will replicate your keystrokes across all panes.
To turn pane synchronization off, use ^ b :setw synchronize-panes off
Summary of commands (the prefix ^b is implied):
% create a veritcal split
" create a horizontal split
o move cursor between panes
x close a pane
:setw synchronize-panes on turn on pane synchronization
:setw synchronize-panes off turn off pane synchronization
d detach from a tmux session (like ^ a d in screen)
To reattach, use tmux a when you next login.
I use tmux every day, and pane syncronization really helped me get through many Red Hat exams.
Small addition from my side - put lines below to your .tmux.conf file:
# Toggle synchronization
bind e setw synchronize-panes on
bind E setw synchronize-panes off
<prefix>+e to enable syncronize panes
<prefix>+E to disable
Also, for anyone interested, consider spending some time reading the Tao of Tmux