Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

Using debian unstable with Gnome 3 but I think this has always happened.

If I log out and then log back in again it seems the X session is restarted or in some way changed.

In any case, when I start a terminal in the second session and re attach the screen, it's no longer possible to start X apps. (message is 'Cannot open display').

Is there an environment variable I can set or command I can run so that the screen session knows the new X details, or do I always have to start a new screen session?

share|improve this question
up vote 4 down vote accepted

I suppose that you have some problem with xauthorization.

Please check if the value of XAUTHORITY environment variable changes each time you start a new X session. If it is true, you have to update this variable in each shell you have inside screen, because their environ contains still the value it has the time you started screen.

share|improve this answer
Bingo, thank you. Setting the XAUTHORITY to the new GDM-created database fixed it. However, there are various other environment variables that have changed which I'd like to preserve. This page suggests a way of grabbing the environment variables when screen starts, and 'loading' them when the session is restored. – Edd Steel Sep 15 '11 at 21:42
@edd-steel I like this idea of automating the environ copy :-) – andcoz Sep 15 '11 at 23:47
me too! I've tried it out and it works pretty well -- but it only loads the environment automatically on new screens (within the existing session) not existing screens. That's just a function call away though! – Edd Steel Sep 16 '11 at 0:37

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.