Detaching and Attaching Sessions

One of tmux’s biggest advantages is that we can fire it up, start up programs or processes inside the tmux environment, and then leave it running in the background by “detaching” from the session.

If we close a regular terminal session, all the programs we have running in that session are killed off. But when we detach from a tmux session, we’re not actually closing tmux. Any programs we started up in that session will stay running. We can then “attach” to the session and pick up where we left off. To demonstrate, let’s create a new named tmux session, start up a program, and detach from the session. First, we create the session:

 
$ ​tmux new -s basic

Then, within the tmux session, we start an application called ...

Get tmux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.