/ linux

Linux Tip of the Week: tmux and panes

Welcome back everyone to another Linux Tip of the Week! Today we're going to talk about multitasking without configuration management.

If you're working on a large scale, you'll definitely want to automate this task through Kickstart, Chef, Ansible, or another configuration management tool. However, when working with a few boxes, standing up a small lab, or playing around with something like Kubernetes, it's nice to know you have a better option than ssh'ing into multiple boxes and repeating commands.

With that, I introduce the synchronize-panes command. You only need Tmux installed, which should be native in your operating system's repositories. It is also available through FreeBSD's pkg and Mac OS X's homebrew.

To start a fresh Tmux session all you need is to enter the 'tmux' command. You can name your sessions and even attach to a detached session but that is beyond the scope of this post.

If you have three shells open accessing three different boxes, or multiple shells accessing the same file, whatever task you need to repeat across multiple shells: enter the Control, b keys and enter

:setw synchronize-panes on

Be sure to include the colon. After that, you'll notice all shells will receive the same input.

That's all it takes! Go ahead and run your apt install or yum enable-repo on multiple systems simultaneously.

To disable, enter Control, b and

:setw synchronize-panes off

Boom, all set.

Bonus Tip

Something that was too cool to leave out: If you want to focus on one pane or shell, put your cursor into the shell you want to focus on and enter Control, b, and then z. All of your panes will disappear allowing you to copy and paste, screenshot, etc. Press the same keys (Control, b, z) to bring all of your panes back into view.

Thanks for reading! Hack on, Penguin Crew.

Linux Tip of the Week: tmux and panes
Share this