tmux: A Beginner's Guide to Terminal Multiplexing
tmux is a terminal multiplexer: it runs multiple shell sessions inside one window and keeps them alive when you disconnect. Start it with tmux, run your work, detach with Ctrl+B then D, and pick it back up later with tmux attach. This is the tool to use for long installs and remote work over SSH.
Start a tmux session
Just run tmux. The status bar at the bottom confirms you are inside. Everything now runs in a persistent session that survives your terminal closing.
Detach and reattach
Press Ctrl+B, release, then press D to detach. The session keeps running in the background. Return to it with tmux attach or tmux attach -t 0 for the first session by number.
Name your sessions
Give a session a name so you can tell them apart: tmux new -s deploy. List sessions with tmux ls and attach to one by name.
Split the window
Inside tmux, split the pane horizontally with Ctrl+B then %, or vertically with Ctrl+B then ". Switch panes with Ctrl+B then an arrow key, and close a pane with exit.
Survive a disconnect
If your SSH connection drops, the tmux session keeps running. Reconnect and reattach to find your work exactly where you left it. This makes tmux the perfect partner for SSH admin work. The tmux reference page covers the full prefix-key map.
Keep learning
Related guides: How to Use the ssh Command to Connect to a Remote Server · How to Schedule Tasks in Linux with cron · How to Monitor Processes with ps and top. Read all tutorials on the Learn Linux blog.