Using tmux

I found this great tutorial on tmux by Daniel Miessler that was designed to take you from “wtf tmux” to “omg tmux” with extreme haste. I’m reproducing parts of that blog post here because I find myself googling it at least three times a day. (Because it’s that useful.) Briefly, tmux is a utility that allows you to connect to a remote server, start a job, and then log off without quitting your job. When you log back in from another location, you can access that job again through tmux. The screen utility also does this, but not as well. For instance, if you have a really long username, then you might not be able to start screen, because edge cases.

Getting Started

The tmux utility might not be installed on the remote server that you’re interested in using. In that case you’ll have to use apt-get or yum to install it if you have those privileges, or bug somebody who does have those privileges. (Having it installed on your local machine doesn’t help you.)

Start a Session

Here, <name> is the name of a new session that you’d like to create.

$ tmux new -s <name>

List the Available Sessions

To get a list of the available sessions, use the easy-to-remember ls command.

$ tmux ls

Attach to Session

Here a is short for attach, and the -t, I don’t know.

$ tmux a -t <name>

Detach from a Session

Short and sweet like a honey dipped dwarf.

$ tmux detach

Kill a Session

This command uses the -t option again that I find difficult to remember.

$ tmux kill-session -t <name>