Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How do I attach a screen? I can see a screen is running in the following output, but can not connect to it.

[root@vishnuvm6 ~]# screen -ls
There is a screen on:
        15941.pts-18.vishnuvm6  (Detached)
1 Socket in /var/run/screen/S-root.

[root@vishnuvm6 ~]# screen -x vishnuvm6
There is no screen to be attached matching vishnuvm6.
share|improve this question
    
From man screen: "-x Attach to a not detached screen session." –  Dennis Williamson Mar 4 '11 at 5:34
    
@Dennis: That just means existing clients, if any, won't get detached. –  grawity Mar 4 '11 at 6:20
    
@grawity: Well, you're right, but that wording is very poor. –  Dennis Williamson Mar 4 '11 at 6:48
add comment

3 Answers

up vote 9 down vote accepted

Since it's the only screen running and it is detached, you can simply:

screen -r

If it was attached, you could:

screen -d -r

to detach it first (I prefer screen -Dr though: "detach and logout first")

or:

screen -x

which will leave all other attached displays intact. A nice trick if you want to tutor on a terminal (for example).


You need to name the screen only if there are other detached screens.

share|improve this answer
add comment

screen -d -r 15941.pts-18.vishnuvm6

share|improve this answer
add comment

I use screen -xRR quite always.

  • If no screen it starts one
  • If a screen exists, attach to it
share|improve this answer
add comment

Your Answer

 
discard

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.