From xdm back to a terminal session opened with 'screen'
Posts: 97
Dear all,
After spending a lot of time in google in order to find a solution to my problem, I am posting this message in the forum because I can't find a suitable solution for it.
I am trying to solve the following problem: I am using the application 'screen', a wonderful application which you can use when you start mepis (mepis 6.0 for me) in runlevel 3 (I need the network services). I log as root at the prompt.
I love to play with the several screens I can open, attach and detach them etc. I came to idea to creat a screen in order to launch xdm and to use some gui apps which I sometimes need. I log as root in xdm, too.
But when I am done with the work with my gui apps, I would like to come back to my terminal 'screen' sessions. I usually kill X in order to get back to xdm (ctrl+alt+backspace).
xdm shows me the remaining terminal sessions (alt+i), but it is impossible for me to get back to them (i.e. impossible to select them from the xdm window, ctrl+alt+f7 or other combinations such as alt+f1 or ctrl+f1 etc. give nothing, too). I have to choose a failsafe session from the xdm menu in order to get a console, and to type 'init 3' which also does not work, i.e. doesn't bring me back to my terminal sessions...
I thought that the problem was related to the user I choose in order to log me in xdm, which is root, i.e. the same use to log in the terminal session. So I did the same procedure again, but this time I opened a xdm session with another user. Unfortunately, I got the same result. It is impossible for me to get back to my terminal session.
How can I come back from the xdm login screen to the terminal sessions I opened with screen?
Thanks a lot for your help!!!
yours
zu
Hi Jon,it is a real
Posts: 97
Hi Jon,
it is a real pleasure to have your support, thank you very much to help me. I am coming to your post in some details:
1. "First, can I get some clarification of your post? Are you saying that you first log onto your box as user root, and start screen as that user?"
Basically, yes. I log onto my box as user root (root@tty1[~]:), and I am starting screen (root@tty1[~]: screen), type enter, get a screen (root@1:) and type ctrl+a+c to get another screen (root@2:). NB: I did the same with another user `zu`, but I got the same result.
2. "Next, are you starting screen, then creating a(nother) screen session (let's say it's screen number 2), in which you then start xdm?"
Yes, exactly.
3. "If that is what you do, when you kill xdm, that particular screen (number 2) is gone, or the entire screen application appears to be gone?"
I start xdm at screen 2 like this: root@2: xdm
xdm starts, and I get the gui login window. When I am there, if I make a ctrl+alt+backspace, I am coming back to the gui login xdm window. It is impossible for me to go back to my terminal session ´root@2´:
4. "Then, a couple comments (please take with large blocks of salt and a glass of water). WHY do you log in as root to start screen? For security's-sake, you can start screen as "you", and then from within one of the sessions, "su" to become root."
I log in as root only because I used to do so with user root, and then I save a lot of things as root so that I did not want to log with another user; but I also have my zu user, and I tried to open a terminal session and screens with zu (zu@tty1[~]:), and then to log in from screen 2 in xdm (zu@2[~]: xdm), and to log in kde with the user root. After that, I got back to xdm as user root in order to come back to my zu@2[~]:, but it was not possible; I did an init 3 in failsafe mode without success; I also tried to ctrl+alt+backspace, but I come again to the xdm login window.
5. "As a matter of fact, I have my .screenrc file set so that when I start screen up, it automatically creates two "root" sessions. Of course, they are not usable until I enter root's password."
You bring me to the following idea: could it be that I have to open another tty session, let us say tty2 instead of tty1 in order to access from a tty 2 session to xdm, and then to log into kde? if yes, how can I do it?
6. "If you have appeared to "lose screen", have you tried the command "screen -l" to see if screen has gone into the background. Or "screen -r" to recover the screen application to your current terminal?"
I did a screen -r, but it supposes that I stay in a terminal session; so, when I have the xdm window in front of me, I can not do a screen -r, even if I can ask for the remaining session; and indeed, xdm let me see the remaining sessions (alt+i), but I do not have any chance to select one of it.
7. "I haven't actively played with screen for a number of weeks, so forgive me if my instructions are not precise."
Not at all Jon, your instructions are at best, thank you so much.
8. "I am not in front of one of my boxes that has "screen" on it at the moment. If you need additional help, let me know and I'll test some things out. If so, give me specific examples (and commands) of what you have tried, and I will try to duplicate it/them."
Thank you again Jon, your help is very important for me. The thing is very basic: open some screen sessions, then go the a screen (f.ex. zu@3[~]:) and type xdm; enter kde (I enter ion3 as wm, a very good one in my opinion), come back to xdm, and then try to come back to your zu@3[~]:. If you can get a routine to this operation, then I am glad to learn it.
yours
zu
EDIT: when I am saying that I start xdm by typing 'xdm' at the prompt, it is naturally mistaken; I am typing kdm in order to start xdm. Sorry for the lapsus.

Good Info
Posts: 5513
Thanks zu for getting back to me with all of the information. Very helpful 
I will have to experiment on my end and see if I can find where things are breaking, so I won't have too much helpful info in this post.
When you INITIALLY start screen, do you already have KDE up and running? In other words, are you already logged into a GUI, and then opening konsole where you then start screen. Or are you ctrl+alt+f1 (or f2...) to one of the text windows to start screen? Or are you starting all your login stuff in a different way?
And yes, thanks for clarifying the "xdm"/"kdm" confusion.
All I can think of at the moment is that something is happening during the stopping of the KDE service that is destroying screen. It might be related to the various DCOP connections used by KDE. I really don't know much about that part of the KDE "magic" so it's probably a false lead at this point. Consider it idle speculation at the moment.
As to your question on item 5 above, "...logging into tty2 to access kde...". It IS POSSIBLE to have multiple GUI sessions running at the same time. That is how the "start new session" ultimately functions in KDE. On most systems the "real KDE" is started on tty6 that is obtained by pressing ctrl+alt+f7. This is normally done automatically. If you were to go to tty2 and do a "startx" you would get an additional GUI running on tty7, that you can get to via ctrl+alt+f8. You can do this up to about 5 times (if you REALLY WANT TO BE CONFUSED). But for it to be successful, you need to make changes in the /etc/kde3/xsessions file. That previous link could be completely wrong. I am not in front of my other box at the moment. I will check it later 
But speculation aside, I don't think that's what you need to do in your present case.
Let me see if I can duplicate some stuff on my end and get back to you 
Jon
The ability to comfortably use a computer is directly proportional to desire to listen, learn, and experiment, and is inversely proportional to the fear, anger, and stubbornness that you show.
Hi Jon, thank you so much
Posts: 97
Hi Jon, thank you so much for your involvment.
"When you INITIALLY start screen, do you already have KDE up and running? In other words, are you already logged into a GUI, and then opening konsole where you then start screen. Or are you ctrl+alt+f1 (or f2...) to one of the text windows to start screen? Or are you starting all your login stuff in a different way?"
I power on my laptop which runs in runlevel 3 (I modified the default which was runlevel 5) and at the prompt ('mepis login:'), I log onto my box as root (i.e. I type my login and my password); I do not do anything else, i.e. I never start kde or do a ctrl+alt+f1 (or f2). After that, I type 'screen' at the prompt and automatically get a new screen.
Why that all? Because I would like to optimize the use of my hardware ressources. In order to do it, I plan to start a maximum of applications in non-gui modus which should enables me to only use kde when I have to (f.ex. in order to edit documents in openoffice etc.).
Thank you again Jon for your collaboration, and see you soon.
Yours
z

I Found Some Things
Posts: 5513
Thanks again zu for clarifying your startup procedures.
I have been able to do preliminary tests. I have started up my (virtual) box and gone into runlevel 3 so KDE is not running initially. I then started screen, both as a regular user, as well as root. Within each instance of screen, I started three virtual screens. From within the first virtual screen of one, I issued the "startx" command. The interesting thing is that I could do this once as a regular user. I could not ctrl+alt+backspace and start it again. I could, however, do it multiple times as user root!
There is a file that is created /home/youraccount/.serverauth.pid, or /root/.serverauth.pid that controls access to the GUI. This file is destroyed when X is stopped.
However, the message that I get as a regular user is "X: user not authorized to run the X server, aborting."
I cannot, at the moment, remember where this access is given. Give me some time to remember, since I think that's where the problem lies.
BTW, when I stop X through ctrl+alt+backspace, screen was not distroyed. Hmm...
Jon
The ability to comfortably use a computer is directly proportional to desire to listen, learn, and experiment, and is inversely proportional to the fear, anger, and stubbornness that you show.
SOLVED
Posts: 97
Hi Jon,
Finally, I have solved it 
It is actually a very simple solution, I wonder that I did not came to it before. Anyway:
1. I power on my machine booting in runlevel 3 (I changed my /etc/inittab in order to boot in runlevel 3);
2. I am loging onto my box as root;
3. from the terminal session, I am starting screen;
4. I am 'making' 2 screen (screen 1 with root(at)1, and screen 2 with root(at)2);
5. in my screen 1, I am running pine in order to check my emails;
6. I switch to screen 2, and I start kdm;
7. I get the kdm gui in order to log in; I do it, and I log in as root (i.e. as the same user as in terminal session); as I have ion3 as wm, ion3 starts;
8. I can perform usual tasks with my gui apps;
9. I want to come back to my terminal screen 2 in order (f.ex.) to check my emails in pine; so
I just stop kdm with the following command in a term:
/etc/init.d/kdm stop
10. and I am directly back to my terminal session from where I started kdm, so back to screen 2.
I reproduced it a lot of times, and it works perfectly; so you can perform tasks in gui runlevel, and other ones in non-gui runlevel, allowing a better allocation of hardware ressources.
Thanks a lot for your support Jon, it brought me on the right path!
yours
zu

Congratulations!
Posts: 5513
Sounds like you got things working well in spite of my help 
It seems so round-a-bout for you to start the gui, login, do stuff, logout, stop the gui (ok, the logout and stop are performed by the "kdm stop" command), but if it works to your satisfaction that's all that matters. One more choice/method to be used to get a task done. I'll add it to my "software utility belt".
Good work! 
Jon
The ability to comfortably use a computer is directly proportional to desire to listen, learn, and experiment, and is inversely proportional to the fear, anger, and stubbornness that you show.
Interesting and Confusing
Posts: 5513
zu, you have a most interesting situation!
First, can I get some clarification of your post? Are you saying that you first log onto your box as user root, and start screen as that user?
Next, are you starting screen, then creating a(nother) screen session (let's say it's screen number 2), in which you then start xdm? If that is what you do, when you kill xdm, that particular screen (number 2) is gone, or the entire screen application appears to be gone?
Then, a couple comments (please take with large blocks of salt and a glass of water). WHY do you log in as root to start screen? For security's-sake, you can start screen as "you", and then from within one of the sessions, "su" to become root. As a matter of fact, I have my .screenrc file set so that when I start screen up, it automatically creates two "root" sessions. Of course, they are not usable until I enter root's password.
If you have appeared to "lose screen", have you tried the command "screen -l" to see if screen has gone into the background. Or "screen -r" to recover the screen application to your current terminal?
I haven't actively played with screen for a number of weeks, so forgive me if my instructions are not precise. I am not in front of one of my boxes that has "screen" on it at the moment. If you need additional help, let me know and I'll test some things out. If so, give me specific examples (and commands) of what you have tried, and I will try to duplicate it/them.
Jon
The ability to comfortably use a computer is directly proportional to desire to listen, learn, and experiment, and is inversely proportional to the fear, anger, and stubbornness that you show.