74

OK I'm new to this. I installed tmux to run a several days experiment. After typing tmux new -s name I got a new window with green banner at the bottom. I compile and run java program. Now I do not know how to exit the window (while leave it running). The bash (or whatever) cursor is not responding because the java program is still running. My solution so far is to quit the Terminal program completely and reopen it again. Any ideas on how to quit the tmux window without exiting the whole Terminal program?

  • 2
    man tmux | less -p detach – jasonwryan Dec 16 '14 at 3:47
136

Detach from currently attached session

Session

Ctrl+ b d or Ctrl+ b :detach

Screen

Ctrl+ a Ctrl+ d or Ctrl+ a :detach

  • You then need to run tmux attach to enter the open session again after re-connecting. – Besi Feb 27 at 17:56
  • I've always done ENTER ~ . This seems nicer. – Thomas Eding 2 days ago
8

The previous answers are incomplete, I believe. What :detach does is to shut down the viewports that are displaying tmux activity. However, tmux itself is still running in the background as you can see by running ps:

myuser 1799 0.0 0.0 2500052 4632 ?? Ss 21Feb16 0:48.39 tmux new-session -s Dev

In fact, even if you quit terminal and start it up again, any tmux processes are STILL running in the background.

To actually kill the tmux process itself, you have to do:

tmux kill-session [-t session_name]

or simply:

kill -9 1799

  • 5
    Imho, it would make more sense to comment about some answer's deficiencies under that particular answer and leave your post as a complete and contained answer without requiring readers to find out which answers are previous and then analyse them. – techraf Mar 2 '16 at 14:59
  • 2
    I think OP specifically wanted the background process (java, in his case) to continue running, so killing it would be counter-productive. More interesting would be to re-attach later to the detached process with tmux attach-session. – ThomasH Mar 27 '18 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.