Linux Tips I Wish I Knew Long Ago: tmux

tmux is a terminal multiplexer. What does that mean? It means you can essentially start different “sessions” in the terminal and switch between them, and they continue to run in the background. It also means you can detach a session and reattach it on a different terminal, which is awesome. I use this feature all the time when I’m on a flakey internet connection and my connection keeps dropping, this allows the tasks to continue running even though the session dropped. It’s also handy for working during a commute. Take a job that takes a long time to run, I can start the session and kick off the job while in the office, disconnect, travel home, reconnect and reattach the session to see the current status and any output.

Start a new named session, called patching:

tmux new -s patching

“Ctrl-b” (or the Ctrl-a prefix) then “d” to detach.

List sessions:

tmux ls
patching: 1 windows (created Tue Feb 9 12:40:11 2016) [159x38]

Attach to the session called patching:

tmux a -t patching

Also tmux is available as a standard package on most linux distributions, so easy to install and use.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.