Tmux - Why Every DevOps Engineer Should Use It
If you've ever had a long-running process die because your SSH connection dropped, you know the pain. I used to rely on nohup to keep things alive in the background, which worked but felt like a hack. Then I discovered tmux, and it changed how I work on remote servers entirely.
The Problem
Any process you run on a remote server through SSH is tied to that connection. Lose the connection, laptop sleeps, Wi-Fi drops, terminal closes, and your process dies with it. That deployment script you've been running for 30 minutes? Gone.
On top of that, if you need to do multiple things on the same server, watch logs, edit files, run scripts, you end up opening multiple SSH connections. That's multiple terminals, multiple authentication steps, and if your internet hiccups, all of them go down.
How Tmux Solves This
Tmux (Terminal Multiplexer) lets you run multiple terminal sessions inside a single SSH connection, and keeps them running even if you disconnect. You can detach, close your laptop, go grab coffee, come back, reattach, and everything is exactly where you left it.
It organizes your workspace into three layers:
Sessions - the outermost container. Persists on the server until you kill it.
Windows - like tabs within a session. Each one is a full-screen terminal.
Panes - splits within a window. Run different things side by side.
Getting Started
Install tmux and start it:
sudo apt install tmux
tmux
You'll notice a green status bar at the bottom. You're now inside tmux. All tmux commands start with a prefix: Ctrl+b, followed by another key.
Session Management
tmux new -s devops-lab # create a named session
tmux ls # list all sessions
tmux attach -t devops-lab # reattach to a session
tmux kill-session -t devops-lab # kill a session
| Shortcut | Action |
|---|---|
Ctrl+b d |
Detach from session (keeps running in background) |
Window Management
Each window is a full terminal, like having multiple tabs in one session, all through a single SSH connection.
| Shortcut | Action |
|---|---|
Ctrl+b c |
Create new window |
Ctrl+b n |
Next window |
Ctrl+b 0-9 |
Jump to window by number |
Ctrl+b , |
Rename current window |
Ctrl+b & |
Close current window |
Pane Management
Panes split a window into multiple terminals. This is where tmux really shines, monitor logs in one pane, edit config in another, and run commands in a third.
| Shortcut | Action |
|---|---|
Ctrl+b " |
Split horizontally |
Ctrl+b % |
Split vertically |
Ctrl+b ←↑→↓ |
Move between panes |
Ctrl+b z |
Toggle full-screen on a pane |
My Typical Workflow
When I SSH into a server for any real work, the first thing I do is:
tmux new -s work
Then I set up my workspace, split into panes, tail logs on one side, keep a shell on the other. If I need to step away, Ctrl+b d to detach. When I'm back, tmux attach -t work picks up right where I left off.
No more lost processes. No more juggling multiple SSH connections. Just one session that survives anything.
If you're working with remote servers in any capacity, make tmux part of your muscle memory. It's one of those tools that once you start using, you wonder how you ever worked without it.