Tmux

Published: May 26th 2016

One of those utilities you bring into your workflow and you just can't live without, Tmux has become my huggable terminal friend. Let me give you a run down of why I love it so much and what you can do...

What Does it do?

Tmux (Terminal Multiplexer) lets you go between multiple running programs within one terminal. If you're like me and pretty much live in the terminal, you'll know how frustrating it is when you lose connection and your processing stops, or you need to go between putty sessions etc. Tmux allows you to create multiple console panes inside one window.

In days gone by I would have used the screen utility, which in some ways is similar - but over the course of this year tmux has become my baby and I wouldn't go back now.

What does it look like?

You can configure multiple panes and windows to your heart's content, keeping items you need and use all the time ready to go and activate every time you launch onto a system.

Tmux Screen Display Output

In this example I've got four panes open on one of my linux machines. I've got htop running {top left}, alpine running for local mail {top right}, a normal terminal open allowing me to run updates and float around the file system fixing things {bottom left} and I've got a bandwidth monitor running {bottom right}.

Pretty cool for a putty session, huh?

What can you do with it?

The beauty of having tmux running is that if your connection dies (your network fails or there's something interrupted in the communication) you can reconnect and get back to where you were with programs still operating.

It has the advantage that many people can connect to the same session at the same time so it's wonderful for demonstrating how to undertake a task to your friends and co-workers. It's a great tool for teams to drop in and out of sessions, see how processes are running and check where your team members left-off in their last round of late-night-fixing.

The ability to set up your terminal with multiple windows and panes gives GUI-like operation from a terminal window.

How to get it

If you're on a Debian-based distro, simply undertake a:

sudo apt-get install tmux

If you're on a Red Hat based system:
sudo yum install tmux

Command Cheat Sheet

From the Command Prompt

Start a session with a target name:

tmux new -s myname

Attach to a named session:
tmux a -t myname

List running sessions:
tmux ls

Kill a session:
tmux kill-session -t myname

Once you're inside a session CTRL+B and then pressing the following buttons controls the tmux interface

Windows (tabs) controls

c create window
w list windows
n next window
p previous window
f find window
, name window
& kill window

Panes (splits) controls

% vertical split
" horizontal split
o swap panes
q show pane numbers
x kill pane
d detach
+ break pane into window (e.g. to select text by mouse to copy)

Playtime

The best thing to do with the system is to get used to working with it, playing around with the different commands and trying out what works well for you. I honestly wouldn't want to live without it now after running it for a year. Until next time...

Happy hacking!
gingerCoder()



Next Item.. ncdu

Previous Item.. Cisco Meraki WAP