Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that the current session name can be accessed with the $STY environment variable, is there a way to get the session name of the parent screen session in case of nested screens?

share|improve this question

I don't believe this is possible; $STY is really the only place to get this information and the old value is masked by the nested screen. You could rename screen to screen-real and replace it with a shell script that did something like this:


if [ "$STY" ]; then
    export PARENT_STY=$STY
exec $0-real "$@"

This would get you access to $PARENT_STY inside a nested screen, but it would only work for a single level of nesting. If you really wanted to you could get substantially more complicated (e.g., treating PARENT_STY like a list and appending values), but that doesn't seem worth the effort.

share|improve this answer
Maybe screen -ls helps. – fboaventura Jan 16 '13 at 1:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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