Home > howto, Tip, tmux > How to get out from tmux session inside a tmux window

How to get out from tmux session inside a tmux window

Here’s how I got stuck:
1) Remote access to a linux serverA
2) Launch tmux, Ctrl-b c to create a new window
3) From the new window, remote access to serverB, then run tmux att under shell to attach an existing tmux session (on serverB)
4) Now if I use the shortcut key Ctrl-b d, I can only detach from the session on serverA, because the tmux session on server B also uses Ctrl-b as the prefix

The fix:
a) Press Ctrl-b n until the window containing the ssh session to server B becomes the current window
b) Press Ctrl-b :
c) Enter tmux command set -g prefix C-a
d) Press Ctrl-b d, tmux session on serverB is now detached, type exit to close the new window created in step 2, this step is optional though as the “nested” tmux session is detached from the ssh shell
e) Press Ctrl-a :
f) Enter tmux command set -g prefix C-b

Step c changes prefix to Ctrl-a so it won’t conflict with the tmux shortcut prefix from serverB. Step f changes the prefix back to Ctrl-b for serverA.

Categories: howto, Tip, tmux
  1. Richard
    August 3, 2012 at 1:21 pm

    Thanks :)

  2. May 23, 2013 at 11:05 pm

    Many thanks for sharing, I really love tmux!

  3. Leo
    May 8, 2014 at 11:24 am

    (optional) Use the following command:
    tmux detach -t \
    Press Enter then detach it.

  4. Leo
    May 8, 2014 at 11:29 am

    Post the command again:
    tmux detach -t \tab

  5. October 2, 2014 at 8:29 pm

    dude, thx

  6. Sergio
    March 31, 2015 at 5:16 pm

    Wow, that was useful.

  1. January 25, 2012 at 2:01 am

Leave a comment