Home » Linux » Kill Attached Screen in Linux

Kill Attached Screen in Linux

Posted by: admin November 29, 2017 Leave a comment


I created a screen “myscreen” in linux and it stopped responding abruptly. I closed the terminal and tried to reopen it. “screen -ls” shows that the screen is Attached. I tried the following commands but nothing responds.

screen -r myscreen
screen -D myscreen
screen -D -RR myscreen
screen -X -S myscreen quit

Any help to reattach to the screen or to kill the screen is very much appreciated.

screen -X -S SCREENID kill

alternatively, you can use the following command

screen -S SCREENNAME -p 0 -X quit

You can view the list of the screen sessions by executing screen -ls


This worked for me very well. Get the screen id via:

screen -r


screen -ls

then kill the screen: kill -9 <screenID>
it now becomes a dead screen,
then wipe it out with: screen -wipe


Create screen from Terminal:

screen -S <screen_name>

To see list of screens:

<screen -ls> or <screen -list>

To go to particular screen:

<screen -x screen_name>

<screen -r screen_name>

Inside screen

To Terminate screen:

give ctrl+d screen will get terminated

To Detach screen:

 give <ctrl+ad>or <screen -d >screen will get detached

To reattach screen:

screen -x <screen_name> or screen -r <screen_name>

To kill a screen from Terminal:

<screen -X -S screen_name quit> 


<screen -X -S screen_name kill>

You can use screen_name or process_id to execute commands.


Suppose your screen id has a pattern. Then you can use the following code to kill all the attached screen at once.

result=$(screen -ls | grep 'pattern_of_screen_id' -o)
for i in $result; 
    `screen -X -S $i quit`;


i usually don’t name my screen instances, so this might not be useful, but did you try screen -r without the ‘myscreen’ part? usually for me, screen -r will show the PIDs of each screen then i can reattach with screen -d -r <PID>


You could create a function to kill all existing sessions. take a look at Kill all detached screen sessions

to list all active sessions use
screen -r

when listed, select with your mouse the session you are interested in and paste it. like this

screen -r


For result find: Click Here

Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells. There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move text regions between windows.