10

I use the screen Screen visual consoles. To detach a screen I need to press Ctrl+A followed by D but some time a session is closed without detaching it. It appears as (Attached) on screen -list:

eduard@eduard-X:~$ screen -list
There are screens on:
        4561.pts-46.eduard-X   (30.03.2015 14:48:51)   (Attached)
        4547.pts-46.eduard-X   (30.03.2015 14:48:33)   (Detached)
        4329.pts-41.eduard-X   (30.03.2015 14:46:28)   (Attached)
        3995.pts-30.eduard-X   (30.03.2015 14:30:01)   (Detached)

If i try to restore it, screen responds that there is no screen to resume:

eduard@eduard-X:~$ screen -r 4329
There is a screen on:
        4329.pts-41.eduard-X   (30.03.2015 14:46:28)   (Attached)
There is no screen to be resumed matching 4329.

Can I still resume a screen that I did not detached properly?

2
  • 2
    Please copy & paste text instead of using graphics.
    – Celada
    Mar 30, 2015 at 12:09
  • @Celada I added text instead of screenshots Mar 30, 2015 at 12:23

3 Answers 3

14

Sure, with

screen -d -r

You can choose which screen to detach and reattach as usual by finding the pid (or complete name) with screen -list.

screen -d -r 12345
9

You should be creating screens with names.

$ screen -S foo

$ screen -list
There are screens on:
        16994.foo       (03/30/15 14:05:13)     (Detached)
        20082.q (12/17/14 18:06:44)     (Detached)
        11008.w (11/12/14 10:52:43)     (Detached)
        1199.irc        (11/12/14 01:34:40)     (Detached)

Then you can reattach screens with

$ screen -dr foo

(which will attach to 16994.foo, detaching any other process) or

$ screen -x i

(which will attach to 1999.irc, which will SHARE the screen with another process)

Naming screens is important I feel.

6

Following a comment suggested in the post I used:

screen -x <session id>

From the man page: screen -x

-x Attach to a not detached screen session. (Multi display mode). Screen refuses to attach from within itself. But when cascading multiple screens, loops are not detected; take care.

Also researching a bit I discovered other uses for this option, Using screen for remote interaction explains that you can connect from multiple terminals, a kind of remote console sharing system, practically you can see and type remotely in a shared environment.

This can be used when teaching students or setting up things with a colleague.

You can try by connecting to the same screen from two different terminals with the same screen id.(screen -x 4329). What you type in one can be seen in the other and vice-versa.

You must log in to answer this question.

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