I use screen in a Ubuntu server.

I have my screen splited in four regions each showing a different window.

The problem is when i detach (or maybe reattach) a get the four windows but only one region and i have to make C-a S all over again?

How can i keep my screen splitted when a reattach?

  • the very short answer is to use tmux instead...
    – Yan Foto
    Commented Dec 8, 2020 at 14:25

6 Answers 6


From the screen FAQ:

(The implied question being, “How do I keep my split windows over a detach?”)

The short is answer is that you can't. The longer answer is that you can fake it.

Splits are a property of your display. The process managing your screen session doesn't really know about them; only the single process that's displaying the session does. Thus, the screen session can't remember the splits because it doesn't know about them, and once you detach, the process that did know about them has exited.

The hack is to use nested screen sessions. Start one session and give it some escape sequence that you won't use much (or just disable its escape character completely). Bind your usual detach key sequence to this screen session. Now, start or attach to your main screen session. All of your work will be done in the inner session, and you can split your display. When you detach, however, it will be the outer session that detaches, so your splits in the inner session will be preserved.

Assuming you use the default escape character, C-a, your alternate screenrc should contain:

escape ""
bindkey ^ad detach
  • 1
    Having spent the past year or two configuring and heavily using nested screen sessions, I recommend it. Over time, the pain of added complexity decreases, while the usefulness of the more flexible setup increases.
    – funroll
    Commented Aug 30, 2012 at 18:51
  • 19
    The new feature, i.e., layout, invalidates this answer!
    – Kadir
    Commented Nov 19, 2013 at 14:21
  • See superuser.com/a/516822/113250 for the "new" built-in layout feature Commented Jan 20, 2019 at 23:53

I found that if you already have some windows set up and you want to save them you can do this:

layout save default

Then when you detach and re-attach to the session the layout should be restored.

Works with Screen version 4.00.03jw4 (FAU) 2-May-06 (Ubuntu 12.04 & 12.10)

Also you may want to create a deamon session as such:

$> screen -dmSU mysession

and then have it always available by calling:

$> screen -r mysession
  • 6
    Much better solution. This should be the accepted answer. (I know why I always scroll down XD)
    – BrainStone
    Commented Apr 13, 2015 at 21:32
  • 1
    Unfortunately it looks like the current version on redhat screen 4.00.03 (FAU) 23-Oct-06 does not have this feature. But it should! Commented May 2, 2017 at 16:13
  • 1
    This is a better answer, but there is an even better answer below which automatically saves the layout every time using .screenrc. Upvote that answer Commented Aug 29, 2019 at 16:38
  • If this was the accepted answer I would have saved 30 minutes today
    – milaniez
    Commented Apr 2, 2020 at 4:23
  • This is officially part of screen since version 4.2.0 which was released on 17/04/2014. (Some distros had it patched in prior to that). Commented Jun 23, 2021 at 23:33

Simply add this line to your ~/.screenrc:

# This line makes Detach and Re-attach without losing the regions/windows layout
layout save default
  • Tested on Screen version 4.08.00 (GNU) 05-Feb-20. Works like a charm.
    – 3r1d
    Commented Apr 30, 2023 at 14:13

In git version, new feature layout was introduced.

from screen(1):

layout new [title]

Create a new layout. The screen will change to one whole region and be switched to the blank window. From here, you build the regions and the windows they show as you desire. The new layout will be numbered with the smallest available integer, starting with zero. You can optionally give a title to your new layout. Otherwise, it will have a default title of "layout". You can always change the title later by using the command layout title.

even if you detached screen session, layout has remember how region was split.

for example, screen start with follow configuration.

layout new
split -v
screen 0
focus next
screen 1
focus bottom
screen 2

And reattach this session, you will able to come back into (last selected) layout which has 3 splitted region.

  • anyone knows what submissions are required to get this (i'n nerdy enough to apply patches but i will never run trunk code(have bad karma :P))
    – borrel
    Commented Aug 23, 2012 at 7:05

It seems that tmux does. This is a new multiplexer project, inspired by screen, but coded from scratch and under a BSD license.

(Sorry if my English is uncomfortable to read :-°)


I've read the whole screen man recently, and there's no common way to do it if screen itself can't remember it automatically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .