Have you ever lost data because the connection to cxin01 (or any remote machine) has died and the process you were running on the remote host was lost? Have you ever closed your laptop and lost a session because the wifi was turned off? If you use tmux you can recover those lost sessions!

tmux allows you to connect to a remote machine, start a process such as a compile, and then detach from that process and reattach at a later time. This means that accidents such as pulling the ethernet cable out of your machine or the battery in your laptop dying are no longer a problem.

You can even start a long-running process at work, detach and go home. After dinner you can reattach to the process and check its progress.

Simple Usage

To start using tmux, just log onto cxin01 (or any other node) in the normal way and then type:


You should then see your terminal looking like this:

The green 'status' line at the bottom indicates your are in a tmux session. You have a shell prompt and you are in the same directory as when you issued the tmux command. So far so good.


Suppose you now start a long-running process in your tmux session:

Now we close the terminal window by clicking the “close window” widget on the terminal window. This simulates an unexpected disconnect. Without tmux we have lost the running process. But tmux lets us recover the session and the running process.

As before, log into cxin01 (or wherever you logged into) and then run this command:

tmux attach

You will reattach to your previous tmux session and will see the still-running command:

Note that the process is still running and we see the output that happened after we killed the connection. Do ^C to kill the running process.

Detaching on Purpose

You can detach from your remote login any time you wish by typing tmux detach. You reattach in the normal way: tmux attach.

Note that if you ^d within a tmux session then tmux will terminate in the way of all programs and not leave a session to reattach to. This includes any other way to terminate a shell session, such as the exit command.

What sessions can I reattach to?

If you might have used tmux last week but aren't sure if you did, you can just try to reattach. But if you are using advanced features like naming sessions, you might not be sure what you can attach to.

In this case, just do:

tmux info

and you will see some information about tmux sessions

Advanced Usage

This doesn't even begin to explain all the things you can do with tmux, which includes:

  • naming sessions
  • manage more than one session
  • split a terminal window into two or more panes
  • share a session with another user
  • and much, much more

Look at the man page and use google.


I use tmux but can't restore my sessions?

Make sure that you login to the target machine before running tmux. tmux can only restore sessions when communications between yourself and the tmux process fail. Running tmux on your desktop machine will not allow you to recover sessions on a remote machine.

cloud/tmux.txt · Last modified: 2014/02/25 10:27 by rwilson
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki