Detaching and Attaching Sessions

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

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

 $ ​​tmux​​ ​​new​​ ​​-s​​ ​​basic

Then, within the tmux session, ...

Get tmux 2 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.