Git, containers and DevOps

Command tmux

Manage terminal sessions and panels

Linux · Bash examples · commands run on the selected server

When to use tmux

Use tmux to maintain server-side terminal sessions while moving between SSH connections. It helps preserve an interactive workspace, but does not replace backups, service supervision or a reliable server.

Syntax

tmux [COMMAND]

Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.

Common options and arguments

new -s NAME
Create a named session.
ls
List of user sessions.
attach -t NAME
Connect to an existing session.

Usage examples

Create a work session

tmux new -s maintenance

A named session is created on the server under the current account.

Show your sessions

tmux ls

Existing sessions on the selected tmux server are listed.

Return to session

tmux attach -t maintenance

The selected session is attached so work can continue from another connection.

Notes and limitations

  • Detach with Ctrl+B, then D. The session normally keeps running after SSH disconnects.
  • tmux preserves an interactive session; use systemd when a service must start after reboot.

Common questions and troubleshooting

How do I leave tmux without closing my work?

The usual default is Ctrl+B followed by D to detach. Reattach after reconnecting to the same server and account.

Why is my session missing after reconnecting?

Check host, user and tmux socket. The server may have rebooted, the session may have exited or a different socket may be selected.

Further help

Options vary by version and distribution. Check the installed documentation with this command: man tmux.