Skip to content

tmux Quick Reference

karlrl edited this page Sep 11, 2017 · 3 revisions

tmux is a handy tool for keeping track of independently running terminal instances. The most basic reason why you would want to use this is if you want to logout while a long-running program is still running. You can detach from a session and then reattach later without disrupting running jobs. There are many in-depth tutorials on how to use this tool online. This page is meant to be a quick reference page for the most basic commands.

List tmux sessions

tmux ls

Create new session

tmux new -s NAME

Detach from current session

tmux detach

or hit CTRL-b and then d (this can be run to detach from a session even if there is a command running in the foreground).

Attach to an existing session

tmux a -t NAME

Kill session

tmux kill-session -t NAME

or if you are still attached to the session type exit.

Fixing outbound SSH with forwarded agent

If you use tmux and SSH agent forwarding, you may find that reattaching to a tmux session after logging out of the server breaks your SSH connections within the session. To fix this, you can run the following (from within the misbehaving tmux session):

eval $(tmux showenv -s SSH_AUTH_SOCK)

or, to keep the fix close at hand create an alias in ~/.bash_aliases:

alias fixssh='eval $(tmux showenv -s SSH_AUTH_SOCK)'
Clone this wiki locally