ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 1.4 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://askubuntu.com/questions/356006/kill-a-screen-session |
| Last Crawled | 2026-02-25 20:30:32 (1 month ago) |
| First Indexed | 2014-04-17 07:17:08 (11 years ago) |
| HTTP Status Code | 200 |
| Meta Title | kill a screen session - Ask Ubuntu |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | This question shows research effort; it is useful and clear
234
Save this question.
Show activity on this post.
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"
slava
4,113
11 gold badges
37 silver badges
66 bronze badges
asked
Oct 9, 2013 at 21:35
4
This answer is useful
290
Save this answer.
Show activity on this post.
Identify the name of the session:
$ screen -
ls
Close a session:
$ screen -XS <session-id> quit
Rationale:
-X
= Execute command,
-S
session PID to execute on
Example:
screen -XS 20411 quit
Source:
innaM's Answer
Miladiouss
340
1 gold badge
4 silver badges
15 bronze badges
answered
Jul 5, 2014 at 9:25
7
This answer is useful
243
Save this answer.
Show activity on this post.
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 session
Source
Ben
1,020
8 silver badges
11 bronze badges
answered
Oct 9, 2013 at 22:25
5
This answer is useful
19
Save this answer.
Show activity on this post.
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.
answered
Mar 19, 2016 at 4:05
2
This answer is useful
14
Save this answer.
Show activity on this post.
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
then
ctrl + \
. That doesn't do anything for me.
answered
Feb 15, 2018 at 21:35
This answer is useful
10
Save this answer.
Show activity on this post.
This will kill all the detached screens:
screen -ls | grep detached | cut -d. -f1 | awk '{print $1}' | xargs kill
This will kill all screens, attached or detached
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
Adaephon
5,061
2 gold badges
31 silver badges
26 bronze badges
answered
Sep 6, 2014 at 10:12
2
This answer is useful
6
Save this answer.
Show activity on this post.
You can use this to kill a session
screen -X -S <name> kill
answered
Dec 17, 2022 at 1:33
This answer is useful
5
Save this answer.
Show activity on this post.
we can also use the
exit
command to terminating screen
answered
Jan 20, 2021 at 10:58
1
This answer is useful
3
Save this answer.
Show activity on this post.
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:
10:42 user ~ $ screen -ls
There is a screen on:
5730.my_screen (Detached)
1 Socket in /tmp/screens/S-user.
10:42 user ~ $ sudo kill 5730
10:43 user ~ $ screen -ls
No Sockets found in /tmp/screens/S-user.
(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.)
answered
Sep 26, 2016 at 14:47
1
This answer is useful
3
Save this answer.
Show activity on this post.
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]
or
sudo kill [sessionId]
You can kill the screen even if it is attached on some other terminal window.
answered
Dec 21, 2018 at 7:18
This answer is useful
0
Save this answer.
Show activity on this post.
Press 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
answered
Sep 19, 2019 at 13:18
This answer is useful
0
Save this answer.
Show activity on this post.
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.
answered
Feb 4, 2021 at 21:06
This answer is useful
0
Save this answer.
Show activity on this post.
Simply, use the
exit
command inside a screen window and if you have a running process press
control + z
before that.
answered
Mar 1, 2022 at 12:40
1
This answer is useful
0
Save this answer.
Show activity on this post.
I believe what is being asked is how to 'quit' a screen session from within screen itself. This would kill all open terminals in the session and leave the user at the prompt for the parent terminal. The session can be suspended from within using CTRL-A, CTRL-Z. But this creates a a problem I'm trying to avoid which is leaving a bunch of opened screen sessions over time and then not knowing which ones are truly active and which ones I should have closed.
After lots of looking, I believe there is no way to do this. Killing them using the PID method is ok, but if there are many sessions open, some of which I might be using, I don't always know which ones to kill.
So what I do when I'm truly done with a screen session is to repeatedly hit CTRL-d to close each terminal individuly until the session completely exits.
This is the best solution I've found.
answered
Feb 10, 2023 at 1:23
This answer is useful
0
Save this answer.
Show activity on this post.
If you already are in the screen with
screen -r
you can use
STRG + ALT + C
to
cancel
the screen and exit.
answered
Mar 11, 2025 at 8:18
You must
log in
to answer this question.
Start asking to get answers
Find the answer to your question by asking.
Ask question
Explore related questions
See similar questions with these tags. |
| Markdown | # 
By clicking “Sign up”, you agree to our [terms of service](https://askubuntu.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://askubuntu.com/legal/privacy-policy).
# OR
Already have an account? [Log in](https://askubuntu.com/users/login)
- [Ubuntu](http://www.ubuntu.com/)
- [Community](http://community.ubuntu.com/)
- [Ask\!](http://askubuntu.com/)
- [Developer](http://developer.ubuntu.com/)
- [Design](http://design.ubuntu.com/)
- [Hardware](http://www.ubuntu.com/certification)
- [Insights](http://insights.ubuntu.com/)
- [Juju](https://jujucharms.com/)
- [Shop](http://shop.ubuntu.com/)
- [More ›](https://askubuntu.com/questions/356006/kill-a-screen-session)
- [Apps](http://apps.ubuntu.com/)
- [Help](https://help.ubuntu.com/)
- [Forum](http://ubuntuforums.org/)
- [Launchpad](http://www.launchpad.net/)
- [MAAS](http://maas.ubuntu.com/)
- [Canonical](http://www.canonical.com/)
[Skip to main content](https://askubuntu.com/questions/356006/kill-a-screen-session#content)
#### Stack Exchange Network
Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
[Visit Stack Exchange](https://stackexchange.com/)
1. - [Tour Start here for a quick overview of the site](https://askubuntu.com/tour)
- [Help Center Detailed answers to any questions you might have](https://askubuntu.com/help)
- [Meta Discuss the workings and policies of this site](https://meta.askubuntu.com/)
- [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/)
2. ### [current community](https://askubuntu.com/)
- [Ask Ubuntu](https://askubuntu.com/)
[help](https://askubuntu.com/help) [chat](https://chat.stackexchange.com/?tab=all&sort=active)
- [Ask Ubuntu Meta](https://meta.askubuntu.com/)
### your communities
[Sign up](https://askubuntu.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006%2Fkill-a-screen-session) or [log in](https://askubuntu.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006%2Fkill-a-screen-session) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
3. [Log in](https://askubuntu.com/users/login?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006%2Fkill-a-screen-session)
4. [Sign up](https://askubuntu.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006%2Fkill-a-screen-session)
[](https://askubuntu.com/)
1. 1. [Home](https://askubuntu.com/)
2. [Questions](https://askubuntu.com/questions)
3. [Unanswered](https://askubuntu.com/unanswered)
4. [AI Assist](https://stackoverflow.com/ai-assist)
5. [Tags](https://askubuntu.com/tags)
6. [Chat](https://chat.stackexchange.com/?tab=all&sort=active)
7. [Users](https://askubuntu.com/users)
8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=askubuntu&so_source=SiteNav)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [kill a screen session](https://askubuntu.com/questions/356006/kill-a-screen-session)
[Ask Question](https://askubuntu.com/questions/ask)
Asked
12 years, 3 months ago
Modified [10 months ago](https://askubuntu.com/questions/356006/kill-a-screen-session?lastactivity "2025-03-11 08:18:01Z")
Viewed 1.1m times
This question shows research effort; it is useful and clear
234
Save this question.
Show activity on this post.
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"
- [gnu-screen](https://askubuntu.com/questions/tagged/gnu-screen "show questions tagged 'gnu-screen'")
[Share](https://askubuntu.com/q/356006 "Short permalink to this question")
Share a link to this question
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this question](https://askubuntu.com/posts/356006/edit)
Follow
Follow this question to receive notifications
[edited Dec 21, 2018 at 9:30](https://askubuntu.com/posts/356006/revisions "show all edits to this post")
[](https://askubuntu.com/users/881020/slava)
[slava](https://askubuntu.com/users/881020/slava)
4,1131111 gold badges3737 silver badges6666 bronze badges
asked Oct 9, 2013 at 21:35
[](https://askubuntu.com/users/81218/johnmerlino)
[JohnMerlino](https://askubuntu.com/users/81218/johnmerlino)
7,9192424 gold badges5656 silver badges7373 bronze badges
4
- 4
in screen v4.x, to kill all sessions, `ps aux | grep "SCREEN" | awk '{print $2}' | xargs kill`
Fredrick Gauss
– [Fredrick Gauss](https://askubuntu.com/users/284463/fredrick-gauss "101 reputation")
2014-11-28 07:33:41 +00:00
[Commented Nov 28, 2014 at 7:33](https://askubuntu.com/questions/356006/kill-a-screen-session#comment760484_356006)
- 3
For the record, you can just do `screen -r porkypig` or `screen -r 23520`, rather than having to include the full string. Screen names are supposed to make things easier, not more complicated.
Mikkel
– [Mikkel](https://askubuntu.com/users/113699/mikkel "343 reputation")
2016-09-26 14:52:44 +00:00
[Commented Sep 26, 2016 at 14:52](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1263825_356006)
- we can also use the `exit` command to terminating screen
Hiren Makwana
– [Hiren Makwana](https://askubuntu.com/users/923812/hiren-makwana "151 reputation")
2021-01-20 10:58:53 +00:00
[Commented Jan 20, 2021 at 10:58](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2228008_356006)
- For the record, you could also do `screen -r` if there's only one screen listed
Ashique Razak
– [Ashique Razak](https://askubuntu.com/users/982926/ashique-razak "101 reputation")
2023-04-12 20:42:10 +00:00
[Commented Apr 12, 2023 at 20:42](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2562420_356006)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 14 Answers 14
Sorted by:
[Reset to default](https://askubuntu.com/questions/356006/kill-a-screen-session?answertab=scoredesc#tab-top)
This answer is useful
290
Save this answer.
Show activity on this post.
1. Identify the name of the session:
```
$ screen -ls
```
1. Close a session:
```
$ screen -XS <session-id> quit
```
- Rationale: `-X` = Execute command, `-S` session PID to execute on
- Example: `screen -XS 20411 quit`
- Source: [innaM's Answer](https://stackoverflow.com/a/1509764/7428659)
[Share](https://askubuntu.com/a/491910 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/491910/edit)
Follow
Follow this answer to receive notifications
[edited Jul 16, 2021 at 8:04](https://askubuntu.com/posts/491910/revisions "show all edits to this post")
[](https://askubuntu.com/users/654275/miladiouss)
[Miladiouss](https://askubuntu.com/users/654275/miladiouss)
34011 gold badge44 silver badges1515 bronze badges
answered Jul 5, 2014 at 9:25
[](https://askubuntu.com/users/25025/shgninc)
[shgnInc](https://askubuntu.com/users/25025/shgninc)
4,47144 gold badges2929 silver badges3131 bronze badges
7
- 1
This was pretty simple. You can simplify it even more by combining the -X -S with -XS
AJ Acevedo
– [AJ Acevedo](https://askubuntu.com/users/263406/aj-acevedo "101 reputation")
2016-11-10 03:34:22 +00:00
[Commented Nov 10, 2016 at 3:34](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1301247_491910)
- 6
You should give credit to [innaM answer](http://stackoverflow.com/a/1509764/562769) if you copy it
Martin Thoma
– [Martin Thoma](https://askubuntu.com/users/10425/martin-thoma "20,775 reputation")
2017-05-01 14:47:55 +00:00
[Commented May 1, 2017 at 14:47](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1432455_491910)
- 2
This answer is most probably the most straightforward, quick yet efficient one.
avia
– [avia](https://askubuntu.com/users/1174096/avia "101 reputation")
2021-07-11 10:01:17 +00:00
[Commented Jul 11, 2021 at 10:01](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2310198_491910)
- Is much better than the accepted answer, and it's working\!
Dmitriy Popov
– [Dmitriy Popov](https://askubuntu.com/users/975890/dmitriy-popov "101 reputation")
2022-09-13 22:10:44 +00:00
[Commented Sep 13, 2022 at 22:10](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2489434_491910)
- 1
i like this one too. plus can always throw it in a loop to get rid of all sessions if needed: `for session in $(screen -ls | grep -oP '\d+\.\w+' | cut -d. -f1); do screen -S "${session}" -X quit; done`.
Danny Blaker
– [Danny Blaker](https://askubuntu.com/users/1107075/danny-blaker "163 reputation")
2023-05-08 06:46:47 +00:00
[Commented May 8, 2023 at 6:46](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2570525_491910)
\| [Show **2** more comments](https://askubuntu.com/questions/356006/kill-a-screen-session "Expand to show all comments on this post")
This answer is useful
243
Save this answer.
Show activity on this post.
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 session
[Source](https://www.gnu.org/software/screen/manual/screen.html#Kill)
[Share](https://askubuntu.com/a/356026 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/356026/edit)
Follow
Follow this answer to receive notifications
[edited Mar 14, 2020 at 0:14](https://askubuntu.com/posts/356026/revisions "show all edits to this post")
[](https://askubuntu.com/users/415503/ben)
[Ben](https://askubuntu.com/users/415503/ben)
1,02088 silver badges1111 bronze badges
answered Oct 9, 2013 at 22:25
[](https://askubuntu.com/users/198002/jacob-minshall)
[Jacob Minshall](https://askubuntu.com/users/198002/jacob-minshall)
2,85611 gold badge1717 silver badges1010 bronze badges
5
- 2
This works if there is a problem with a process running inside the screen, but not if there is a problem with screen itself. That is the case 99% of the time, and has the added benefit of only affecting a single window within the screen rather than terminating all windows.
Mikkel
– [Mikkel](https://askubuntu.com/users/113699/mikkel "343 reputation")
2016-09-26 14:51:18 +00:00
[Commented Sep 26, 2016 at 14:51](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1263822_356026)
- 2
It is to kill a window, not a session
Eric Wang
– [Eric Wang](https://askubuntu.com/users/760921/eric-wang "101 reputation")
2019-08-10 00:47:17 +00:00
[Commented Aug 10, 2019 at 0:47](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1941349_356026)
- 2
Ctrl + a then UPPERCASE K, then y
user2965003
– [user2965003](https://askubuntu.com/users/1580838/user2965003 "101 reputation")
2022-03-22 10:10:05 +00:00
[Commented Mar 22, 2022 at 10:10](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2424458_356026)
- 2
`Ctrl` + `A` + `K` doesn't work for me.
Peyman
– [Peyman](https://askubuntu.com/users/727107/peyman "208 reputation")
2022-11-25 17:48:49 +00:00
[Commented Nov 25, 2022 at 17:48](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2516999_356026)
- 1
To clarify, you need to press Ctrl + A, then let go of all the keys and press k.
ToDo
– [ToDo](https://askubuntu.com/users/894766/todo "101 reputation")
2024-06-17 08:15:38 +00:00
[Commented Jun 17, 2024 at 8:15](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2665431_356026)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
19
Save this answer.
Show activity on this post.
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.
[Share](https://askubuntu.com/a/747688 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/747688/edit)
Follow
Follow this answer to receive notifications
[edited Mar 3, 2021 at 19:40](https://askubuntu.com/posts/747688/revisions "show all edits to this post")
answered Mar 19, 2016 at 4:05
[](https://askubuntu.com/users/401493/brian-thomas)
[Brian Thomas](https://askubuntu.com/users/401493/brian-thomas)
34222 silver badges88 bronze badges
2
- 7
Note that this will kill all running screens, which may or may not be what you want.
Mikkel
– [Mikkel](https://askubuntu.com/users/113699/mikkel "343 reputation")
2016-09-26 14:57:14 +00:00
[Commented Sep 26, 2016 at 14:57](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1263830_747688)
- 2
Not a good choice. I've been doing it for some time. Sometimes it causes bad behaviors (e.g. logging out from your user account immediately). Also, as @Mikkel mentioned, it could cause to close all your screens, which would not be what you want. Sometimes you need to keep running some (e.g. some are running by system) and stop some other screens.
MAChitgarha
– [MAChitgarha](https://askubuntu.com/users/701098/machitgarha "434 reputation")
2018-09-04 05:14:40 +00:00
[Commented Sep 4, 2018 at 5:14](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1758588_747688)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
14
Save this answer.
Show activity on this post.
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` then `ctrl + \`. That doesn't do anything for me.
[Share](https://askubuntu.com/a/1006605 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/1006605/edit)
Follow
Follow this answer to receive notifications
answered Feb 15, 2018 at 21:35
[](https://askubuntu.com/users/795711/lizp)
[lizp](https://askubuntu.com/users/795711/lizp)
14111 silver badge22 bronze badges
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
10
Save this answer.
Show activity on this post.
This will kill all the detached screens:
```
screen -ls | grep detached | cut -d. -f1 | awk '{print $1}' | xargs kill
```
This will kill all screens, attached or detached
```
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
```
[Share](https://askubuntu.com/a/520792 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/520792/edit)
Follow
Follow this answer to receive notifications
[edited Sep 6, 2014 at 13:59](https://askubuntu.com/posts/520792/revisions "show all edits to this post")
[](https://askubuntu.com/users/217016/adaephon)
[Adaephon](https://askubuntu.com/users/217016/adaephon)
5,06122 gold badges3131 silver badges2626 bronze badges
answered Sep 6, 2014 at 10:12
[](https://askubuntu.com/users/324207/user324207)
[user324207](https://askubuntu.com/users/324207/user324207)
10111 silver badge22 bronze badges
2
- Is the `awk` step really necessary?
Martin J.H.
– [Martin J.H.](https://askubuntu.com/users/195654/martin-j-h "141 reputation")
2022-07-27 08:05:15 +00:00
[Commented Jul 27, 2022 at 8:05](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2472267_520792)
- I am an grep/awk/xargs noob and always will be. But based on your answer I built my own shell alias. Just in case this may be useful for someone: `alias killscreen='screen -ls | grep -i attached | awk '\''{print $1}'\'' | xargs -L1 bash -c '\''screen -XS $0 quit'\'''` (kills all attached sessions)
Matthias W.
– [Matthias W.](https://askubuntu.com/users/425912/matthias-w "101 reputation")
2023-12-25 12:23:26 +00:00
[Commented Dec 25, 2023 at 12:23](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2624209_520792)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
6
Save this answer.
Show activity on this post.
You can use this to kill a session
```
screen -X -S <name> kill
```
[Share](https://askubuntu.com/a/1445964 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1445964/edit)
Follow
Follow this answer to receive notifications
answered Dec 17, 2022 at 1:33
[](https://askubuntu.com/users/1658177/furkan-ozturk)
[Furkan ozturk](https://askubuntu.com/users/1658177/furkan-ozturk)
16111 silver badge22 bronze badges
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
5
Save this answer.
Show activity on this post.
we can also use the `exit` command to terminating screen
[Share](https://askubuntu.com/a/1309507 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1309507/edit)
Follow
Follow this answer to receive notifications
answered Jan 20, 2021 at 10:58
[](https://askubuntu.com/users/923812/hiren-makwana)
[Hiren Makwana](https://askubuntu.com/users/923812/hiren-makwana)
15111 silver badge33 bronze badges
1
- Easiest and most straightforward approach! You will, of course, first need to reattach to the screen session.
gillesC
– [gillesC](https://askubuntu.com/users/447763/gillesc "101 reputation")
2021-07-16 08:36:17 +00:00
[Commented Jul 16, 2021 at 8:36](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2312129_1309507)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
3
Save this answer.
Show activity on this post.
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:
```
10:42 user ~ $ screen -ls
There is a screen on:
5730.my_screen (Detached)
1 Socket in /tmp/screens/S-user.
10:42 user ~ $ sudo kill 5730
10:43 user ~ $ screen -ls
No Sockets found in /tmp/screens/S-user.
```
(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.)
[Share](https://askubuntu.com/a/829901 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0")
[Improve this answer](https://askubuntu.com/posts/829901/edit)
Follow
Follow this answer to receive notifications
answered Sep 26, 2016 at 14:47
[](https://askubuntu.com/users/113699/mikkel)
[Mikkel](https://askubuntu.com/users/113699/mikkel)
34333 silver badges1010 bronze badges
1
- After 6 hours breaking my head all over internet... yours was the only answer that worked. Thanks mate\!
kRazzy R
– [kRazzy R](https://askubuntu.com/users/741721/krazzy-r "103 reputation")
2017-09-30 06:43:36 +00:00
[Commented Sep 30, 2017 at 6:43](https://askubuntu.com/questions/356006/kill-a-screen-session#comment1535312_829901)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
3
Save this answer.
Show activity on this post.
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]` or
`sudo kill [sessionId]`
You can kill the screen even if it is attached on some other terminal window.
[Share](https://askubuntu.com/a/1103515 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1103515/edit)
Follow
Follow this answer to receive notifications
answered Dec 21, 2018 at 7:18
[](https://askubuntu.com/users/803959/siddhant)
[Siddhant](https://askubuntu.com/users/803959/siddhant)
3122 bronze badges
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
Press 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
[Share](https://askubuntu.com/a/1175263 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1175263/edit)
Follow
Follow this answer to receive notifications
answered Sep 19, 2019 at 13:18
[](https://askubuntu.com/users/437738/dilushan)
[Dilushan](https://askubuntu.com/users/437738/dilushan)
111 bronze badge
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
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.
[Share](https://askubuntu.com/a/1313703 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1313703/edit)
Follow
Follow this answer to receive notifications
answered Feb 4, 2021 at 21:06
[](https://askubuntu.com/users/1179119/utkarsh)
[Utkarsh](https://askubuntu.com/users/1179119/utkarsh)
1
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
Simply, use the `exit` command inside a screen window and if you have a running process press `control + z` before that.
[Share](https://askubuntu.com/a/1395422 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1395422/edit)
Follow
Follow this answer to receive notifications
answered Mar 1, 2022 at 12:40
[](https://askubuntu.com/users/1575266/yavar-yeganeh)
[Yavar Yeganeh](https://askubuntu.com/users/1575266/yavar-yeganeh)
1
1
- This doesn't answer the question (how to kill a screen session, as opposed how to exit normally) and it doesn't expand on the other answers. A good answer might cover the normal exiting procedure and then document a few ways you can kill screen if that doesn't work.
Coljac
– [Coljac](https://askubuntu.com/users/328374/coljac "642 reputation")
2022-03-02 22:38:02 +00:00
[Commented Mar 2, 2022 at 22:38](https://askubuntu.com/questions/356006/kill-a-screen-session#comment2416188_1395422)
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
I believe what is being asked is how to 'quit' a screen session from within screen itself. This would kill all open terminals in the session and leave the user at the prompt for the parent terminal. The session can be suspended from within using CTRL-A, CTRL-Z. But this creates a a problem I'm trying to avoid which is leaving a bunch of opened screen sessions over time and then not knowing which ones are truly active and which ones I should have closed.
After lots of looking, I believe there is no way to do this. Killing them using the PID method is ok, but if there are many sessions open, some of which I might be using, I don't always know which ones to kill.
So what I do when I'm truly done with a screen session is to repeatedly hit CTRL-d to close each terminal individuly until the session completely exits.
This is the best solution I've found.
[Share](https://askubuntu.com/a/1454307 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1454307/edit)
Follow
Follow this answer to receive notifications
answered Feb 10, 2023 at 1:23
[](https://askubuntu.com/users/618365/harry-slaughter)
[Harry Slaughter](https://askubuntu.com/users/618365/harry-slaughter)
10111 bronze badge
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
This answer is useful
0
Save this answer.
Show activity on this post.
If you already are in the screen with `screen -r` you can use
```
STRG + ALT + C
```
to *cancel* the screen and exit.
[Share](https://askubuntu.com/a/1543412 "Short permalink to this answer")
Share a link to this answer
Copy link
[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0")
[Improve this answer](https://askubuntu.com/posts/1543412/edit)
Follow
Follow this answer to receive notifications
answered Mar 11, 2025 at 8:18
[](https://askubuntu.com/users/658475/isengo)
[Isengo](https://askubuntu.com/users/658475/isengo)
51855 silver badges1212 bronze badges
[Add a comment](https://askubuntu.com/questions/356006/kill-a-screen-session "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \|
## You must [log in](https://askubuntu.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://askubuntu.com/questions/ask)
Explore related questions
- [gnu-screen](https://askubuntu.com/questions/tagged/gnu-screen "show questions tagged 'gnu-screen'")
See similar questions with these tags.
- The Overflow Blog
- [Are you learning with AI? We want to know about it\!](https://stackoverflow.blog/2026/01/29/are-you-learning-with-ai-we-want-to-know-about-it/?cb=1)
- [Wanna see a CSS magic trick?](https://stackoverflow.blog/2026/01/30/wanna-see-a-css-magic-trick/?cb=1)
- Featured on Meta
- [Results of the January 2026 Community Asks Sprint: Community Badges](https://meta.stackexchange.com/questions/417043/results-of-the-january-2026-community-asks-sprint-community-badges?cb=1)
- [All users on Stack Exchange can now participate in chat](https://meta.stackexchange.com/questions/417109/all-users-on-stack-exchange-can-now-participate-in-chat?cb=1)
- [2025: a year in moderation](https://meta.askubuntu.com/questions/20764/2025-a-year-in-moderation?cb=1)
- [End of Life Notice: Ubuntu 25.04 (Plucky Puffin) reached End of Life on...](https://meta.askubuntu.com/questions/20765/end-of-life-notice-ubuntu-25-04-plucky-puffin-reached-end-of-life-on-january?cb=1 "End of Life Notice: Ubuntu 25.04 (Plucky Puffin) reached End of Life on January 15, 2026")
#### Related
[5](https://askubuntu.com/questions/92679/session-freezes-when-using-the-screen-command?rq=1 "Question score (upvotes - downvotes)")
[Session freezes when using the screen command](https://askubuntu.com/questions/92679/session-freezes-when-using-the-screen-command?rq=1)
[251](https://askubuntu.com/questions/124897/how-do-i-detach-a-screen-session-from-a-terminal?rq=1 "Question score (upvotes - downvotes)")
[How do I detach a screen session from a terminal?](https://askubuntu.com/questions/124897/how-do-i-detach-a-screen-session-from-a-terminal?rq=1)
[12](https://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local?rq=1 "Question score (upvotes - downvotes)")
[Run a screen session on boot from rc.local](https://askubuntu.com/questions/261899/run-a-screen-session-on-boot-from-rc-local?rq=1)
[150](https://askubuntu.com/questions/302662/reattaching-to-an-existing-screen-session?rq=1 "Question score (upvotes - downvotes)")
[Reattaching to an existing screen session](https://askubuntu.com/questions/302662/reattaching-to-an-existing-screen-session?rq=1)
[0](https://askubuntu.com/questions/355965/finding-whats-running-on-screen-session?rq=1 "Question score (upvotes - downvotes)")
[finding what's running on screen session](https://askubuntu.com/questions/355965/finding-whats-running-on-screen-session?rq=1)
[1](https://askubuntu.com/questions/809188/how-to-connect-to-a-private-screen-session?rq=1 "Question score (upvotes - downvotes)")
[How to connect to a "Private" screen session](https://askubuntu.com/questions/809188/how-to-connect-to-a-private-screen-session?rq=1)
[3](https://askubuntu.com/questions/823156/how-to-check-if-screen-session-is-running?rq=1 "Question score (upvotes - downvotes)")
[How to check if screen session is running?](https://askubuntu.com/questions/823156/how-to-check-if-screen-session-is-running?rq=1)
[1](https://askubuntu.com/questions/976341/terminate-gnu-parallel-in-screen-session-letting-jobs-finish?rq=1 "Question score (upvotes - downvotes)")
[Terminate GNU Parallel in Screen Session letting jobs finish](https://askubuntu.com/questions/976341/terminate-gnu-parallel-in-screen-session-letting-jobs-finish?rq=1)
[0](https://askubuntu.com/questions/1146533/linux-closing-screen-session-terminates-process?rq=1 "Question score (upvotes - downvotes)")
[Linux - Closing screen session terminates process](https://askubuntu.com/questions/1146533/linux-closing-screen-session-terminates-process?rq=1)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [What arcade game appears next to Karate Champ in the movie "Somnium"?](https://gaming.stackexchange.com/questions/417718/what-arcade-game-appears-next-to-karate-champ-in-the-movie-somnium)
- [Is This Video on Bell's Theorem Wrong?](https://physics.stackexchange.com/questions/868447/is-this-video-on-bells-theorem-wrong)
- [Are there dye which turn infrared lights into visible colored light?](https://physics.stackexchange.com/questions/868478/are-there-dye-which-turn-infrared-lights-into-visible-colored-light)
- [Is the Torah really \<against\> us in the ark of the covenant in Deut. 31:26?](https://hermeneutics.stackexchange.com/questions/114353/is-the-torah-really-against-us-in-the-ark-of-the-covenant-in-deut-3126)
- [Time period of a pendulum filled with water](https://physics.stackexchange.com/questions/868498/time-period-of-a-pendulum-filled-with-water)
- [How to do the most simple and least signal-loss coax-run for Cable TV/Internet (like Comcast)?](https://diy.stackexchange.com/questions/328959/how-to-do-the-most-simple-and-least-signal-loss-coax-run-for-cable-tv-internet)
- [What makes something a tool?](https://philosophy.stackexchange.com/questions/135731/what-makes-something-a-tool)
- [Explain relative mode in LilyPond](https://music.stackexchange.com/questions/143148/explain-relative-mode-in-lilypond)
- [Completeness of a \`fgets()\` test code](https://codereview.stackexchange.com/questions/301145/completeness-of-a-fgets-test-code)
- [Is the expression "give \[someone\] leave to \[do something\]" obsolescent?](https://english.stackexchange.com/questions/638827/is-the-expression-give-someone-leave-to-do-something-obsolescent)
- [What is the left adjoint to sheaf pullback?](https://mathoverflow.net/questions/507536/what-is-the-left-adjoint-to-sheaf-pullback)
- [How is numerical precision/accuracy determined when converting RA/Dec in sexagesimal format to decimal degrees for angular separation calculations?](https://astronomy.stackexchange.com/questions/62154/how-is-numerical-precision-accuracy-determined-when-converting-ra-dec-in-sexages)
- [Unauthorized Withdrawal After Sharing Bank Details: Questions on Risk and Prevention](https://money.stackexchange.com/questions/169228/unauthorized-withdrawal-after-sharing-bank-details-questions-on-risk-and-preven)
- [Why does Susan Sto Helit get involved in The Hogfather?](https://scifi.stackexchange.com/questions/303071/why-does-susan-sto-helit-get-involved-in-the-hogfather)
- [Make certain item "titles" of enumerate bold text](https://tex.stackexchange.com/questions/758981/make-certain-item-titles-of-enumerate-bold-text)
- [What are some ways to represent uncertainty on a map?](https://stats.stackexchange.com/questions/674558/what-are-some-ways-to-represent-uncertainty-on-a-map)
- [My thesis was published without my approval](https://academia.stackexchange.com/questions/225777/my-thesis-was-published-without-my-approval)
- [Understanding PKCE flow security after the first request](https://security.stackexchange.com/questions/286668/understanding-pkce-flow-security-after-the-first-request)
- [Does this practice of omitting an initial quotation mark have precedent?](https://literature.stackexchange.com/questions/31467/does-this-practice-of-omitting-an-initial-quotation-mark-have-precedent)
- [Can a Windows administrator impersonate a user with lower privileges and execute a command?](https://superuser.com/questions/1934234/can-a-windows-administrator-impersonate-a-user-with-lower-privileges-and-execute)
- [Is it a good idea to connect LEDs in parallel instead of series (string configuration) to TPS92511 work with lower values of voltages like Vin = 5V?](https://electronics.stackexchange.com/questions/765077/is-it-a-good-idea-to-connect-leds-in-parallel-instead-of-series-string-configur)
- [How to intersect gift and commodity economies in ancient civilizations?](https://worldbuilding.stackexchange.com/questions/272501/how-to-intersect-gift-and-commodity-economies-in-ancient-civilizations)
- [Was Karl Marx a Marxist?](https://philosophy.stackexchange.com/questions/135684/was-karl-marx-a-marxist)
- [What's the official site for Thailand e-Visa applications](https://travel.stackexchange.com/questions/203179/whats-the-official-site-for-thailand-e-visa-applications)
[Question feed](https://askubuntu.com/feeds/question/356006 "Feed of this question and its answers")
# Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

# Why are you flagging this comment?
It contains harassment, bigotry or abuse.
This comment attacks a person or group. Learn more in our [Abusive behavior policy](https://askubuntu.com/conduct/abusive-behavior).
It's unfriendly or unkind.
This comment is rude or condescending. Learn more in our [Code of Conduct](https://askubuntu.com/conduct/abusive-behavior).
Not needed.
This comment is not relevant to the post.
```
```
Enter at least 6 characters
Something else.
A problem not listed above. Try to be as specific as possible.
```
```
Enter at least 6 characters
Flag comment
Cancel
You have 0 flags left today
# 
# Hang on, you can't upvote just yet.
You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation)
Instead, you can save this post to reference later.
Save this post for later
Not now
##### [Ask Ubuntu](https://askubuntu.com/)
- [Tour](https://askubuntu.com/tour)
- [Help](https://askubuntu.com/help)
- [Chat](https://chat.stackexchange.com/?tab=all&sort=active)
- [Contact](https://askubuntu.com/contact)
- [Feedback](https://meta.askubuntu.com/)
##### [Company](https://stackoverflow.co/)
- [Stack Overflow](https://stackoverflow.com/)
- [Stack Internal](https://stackoverflow.co/internal/)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/)
- [Stack Ads](https://stackoverflow.co/advertising/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.1.29.39263
Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence. |
| Readable Markdown | This question shows research effort; it is useful and clear
234
Save this question.
Show activity on this post.
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"
[](https://askubuntu.com/users/881020/slava)
[slava](https://askubuntu.com/users/881020/slava)
4,11311 gold badges37 silver badges66 bronze badges
asked Oct 9, 2013 at 21:35
[](https://askubuntu.com/users/81218/johnmerlino)
4
This answer is useful
290
Save this answer.
Show activity on this post.
1. Identify the name of the session:
```
$ screen -ls
```
1. Close a session:
```
$ screen -XS <session-id> quit
```
- Rationale: `-X` = Execute command, `-S` session PID to execute on
- Example: `screen -XS 20411 quit`
- Source: [innaM's Answer](https://stackoverflow.com/a/1509764/7428659)
[](https://askubuntu.com/users/654275/miladiouss)
[Miladiouss](https://askubuntu.com/users/654275/miladiouss)
3401 gold badge4 silver badges15 bronze badges
answered Jul 5, 2014 at 9:25
[](https://askubuntu.com/users/25025/shgninc)
7
This answer is useful
243
Save this answer.
Show activity on this post.
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 session
[Source](https://www.gnu.org/software/screen/manual/screen.html#Kill)
[](https://askubuntu.com/users/415503/ben)
[Ben](https://askubuntu.com/users/415503/ben)
1,0208 silver badges11 bronze badges
answered Oct 9, 2013 at 22:25
[](https://askubuntu.com/users/198002/jacob-minshall)
5
This answer is useful
19
Save this answer.
Show activity on this post.
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.
answered Mar 19, 2016 at 4:05
[](https://askubuntu.com/users/401493/brian-thomas)
2
This answer is useful
14
Save this answer.
Show activity on this post.
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` then `ctrl + \`. That doesn't do anything for me.
answered Feb 15, 2018 at 21:35
[](https://askubuntu.com/users/795711/lizp)
This answer is useful
10
Save this answer.
Show activity on this post.
This will kill all the detached screens:
```
screen -ls | grep detached | cut -d. -f1 | awk '{print $1}' | xargs kill
```
This will kill all screens, attached or detached
```
screen -ls | grep pts | cut -d. -f1 | awk '{print $1}' | xargs kill
```
[](https://askubuntu.com/users/217016/adaephon)
[Adaephon](https://askubuntu.com/users/217016/adaephon)
5,0612 gold badges31 silver badges26 bronze badges
answered Sep 6, 2014 at 10:12
[](https://askubuntu.com/users/324207/user324207)
2
This answer is useful
6
Save this answer.
Show activity on this post.
You can use this to kill a session
```
screen -X -S <name> kill
```
answered Dec 17, 2022 at 1:33
[](https://askubuntu.com/users/1658177/furkan-ozturk)
This answer is useful
5
Save this answer.
Show activity on this post.
we can also use the `exit` command to terminating screen
answered Jan 20, 2021 at 10:58
[](https://askubuntu.com/users/923812/hiren-makwana)
1
This answer is useful
3
Save this answer.
Show activity on this post.
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:
```
10:42 user ~ $ screen -ls
There is a screen on:
5730.my_screen (Detached)
1 Socket in /tmp/screens/S-user.
10:42 user ~ $ sudo kill 5730
10:43 user ~ $ screen -ls
No Sockets found in /tmp/screens/S-user.
```
(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.)
answered Sep 26, 2016 at 14:47
[](https://askubuntu.com/users/113699/mikkel)
1
This answer is useful
3
Save this answer.
Show activity on this post.
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]` or
`sudo kill [sessionId]`
You can kill the screen even if it is attached on some other terminal window.
answered Dec 21, 2018 at 7:18
[](https://askubuntu.com/users/803959/siddhant)
This answer is useful
0
Save this answer.
Show activity on this post.
Press 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
answered Sep 19, 2019 at 13:18
[](https://askubuntu.com/users/437738/dilushan)
This answer is useful
0
Save this answer.
Show activity on this post.
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.
answered Feb 4, 2021 at 21:06
[](https://askubuntu.com/users/1179119/utkarsh)
This answer is useful
0
Save this answer.
Show activity on this post.
Simply, use the `exit` command inside a screen window and if you have a running process press `control + z` before that.
answered Mar 1, 2022 at 12:40
[](https://askubuntu.com/users/1575266/yavar-yeganeh)
1
This answer is useful
0
Save this answer.
Show activity on this post.
I believe what is being asked is how to 'quit' a screen session from within screen itself. This would kill all open terminals in the session and leave the user at the prompt for the parent terminal. The session can be suspended from within using CTRL-A, CTRL-Z. But this creates a a problem I'm trying to avoid which is leaving a bunch of opened screen sessions over time and then not knowing which ones are truly active and which ones I should have closed.
After lots of looking, I believe there is no way to do this. Killing them using the PID method is ok, but if there are many sessions open, some of which I might be using, I don't always know which ones to kill.
So what I do when I'm truly done with a screen session is to repeatedly hit CTRL-d to close each terminal individuly until the session completely exits.
This is the best solution I've found.
answered Feb 10, 2023 at 1:23
[](https://askubuntu.com/users/618365/harry-slaughter)
This answer is useful
0
Save this answer.
Show activity on this post.
If you already are in the screen with `screen -r` you can use
```
STRG + ALT + C
```
to *cancel* the screen and exit.
answered Mar 11, 2025 at 8:18
[](https://askubuntu.com/users/658475/isengo)
## You must [log in](https://askubuntu.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F356006) to answer this question.
Start asking to get answers
Find the answer to your question by asking.
[Ask question](https://askubuntu.com/questions/ask)
Explore related questions
See similar questions with these tags. |
| Shard | 53 (laksa) |
| Root Hash | 9277990770814737653 |
| Unparsed URL | com,askubuntu!/questions/356006/kill-a-screen-session s443 |