I'm trying to kill a screen session. I noticed a lot of other related questions, but none of those answers are working for me. I am trying to kill the following session:
screen -ls
There is a screen on:
23520.pts-6.porkypig (09/30/2013 02:49:47 PM) (Detached)
1 Socket in /var/run/screen/S-root.
screen -r 23520.pts-6.porkypig
Now I am in the session. According to the documentation:
http://www.gnu.org/software/screen/manual/screen.html#Quit
I am supposed to press "control a" and then "control \". I do that and nothing happens.
Another solution said to press Ctrl+a and type :quit. However, again it doesn't do anything. In fact, pressing control+a, absolutely nothing happens afterwards except a message "No Other Window"
first you need to re attach to the screen session
screen -r 23520
as you have done. Then press ctrl + a and then a k and press y when it asks if you really want to kill the sessionSource
-X
= Execute command,-S
session PID to execute onscreen -XS 20411 quit
This command will kill all screen sessions, if that is desired:
So with all those official suggestions, I have one here that i feel is easier, and just as effective, and kind of more straight forward:
pkill screen
Who wants to go into an unknown and un-needed screen just to press in a couple commands that most might barely remember? This avoids going into it at all, and kills it straight off.
Plus, if you have more than one, this will take them all in one fell swoop.
This will kill all the detached screens:
This will kill all screens, attached or detached
Like you, I wanted to kill my screen session and found the documentation unhelpful. Convinced that there must be a keyboard shortcut, I found that
ctrl + a
then\
works
I then get the prompt: "Really quit and kill all your windows [y\n]"
I am not sure why the documentation says
ctrl + a
thenctrl + \
. That doesn't do anything for me.I encountered this problem when updating screen. The
screen
command would hang when attempting to reattach the session, regardless of how many-D
or-R
I added to the command. However,screen -ls
conveniently provides the pid of the session, allowing you to intervene using the following:(This is similar to Brian Thomas's answer, but his will kill all running screen sessions, which may not be what you want if you have multiple screens open but only one misbehaving.)
You can find the process id of the attached running screen. I found it same as the session id which you can get by command:
screen -ls
And you can use following command to kill that process:
kill [sessionId]
orsudo kill [sessionId]
You can kill the screen even if it is attached on some other terminal window.
we can also use the
exit
command to terminating screenPress ctrl+d to kill screen window. Repeat this until you kill all screen windows. Once you ran out all windows screen will kill the session and terminating. Shortest solution if you not having many windows
You can just simply type exit while in a recording mode, I found out it to be most convenient as it directly exits the running screen.