tmux Cheat Sheet for Remote Work

tmux Cheat Sheet for Remote Work

Revised
Published

~ 2 min read


tmux solves a specific and common problem: you need to start work in a terminal, but you cannot stay connected to that terminal forever.

The most useful example is remote work over SSH. You can connect to a server, start a long-running command inside tmux, disconnect, and come back later without losing the process.

Start a Session, Detach, and Reconnect

This is the core workflow most people need.

# Connect to the remote host
ssh user@server

# Start a named tmux session
tmux new -s backup

# Run your long-running task
./run-nightly-backup.sh

Detach from the session without stopping the task:

Ctrl-b d

Later, reconnect and resume the same session:

ssh user@server
tmux attach -t backup

Essential tmux Commands

If you only remember a few commands, remember these:

  • Start a new named session: tmux new -s work
  • List sessions: tmux ls
  • Reattach to a session: tmux attach -t work
  • Detach from the current session: Ctrl-b d
  • Create a new window: Ctrl-b c
  • Rename the current window: Ctrl-b ,
  • Move to the next window: Ctrl-b n
  • Move to the previous window: Ctrl-b p
  • Split the current pane left/right: Ctrl-b %
  • Split the current pane top/bottom: Ctrl-b "
  • Move between panes: Ctrl-b o
  • Kill a session when you are finished: tmux kill-session -t work

Verify the Session Is Still Running

After you disconnect, you can check that the session still exists:

tmux ls

If the session name appears in the output, you can reattach to it later.

Caveats

  • tmux uses Ctrl-b as the default prefix key. Press that first, then the command key.
  • Name sessions after the job or project so they are easy to find later.
  • Clean up old sessions when you are done, especially on shared servers.

Summary

tmux is most valuable when you treat it as a way to keep terminal work alive across disconnects. Start a named session, do the work inside it, detach when needed, and reattach later.

If you want more than the basics, continue with tmux Advanced Workflows.

all posts →