Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a lot of screens on my server. With screen -ls I get:

 There are screens on:
    12858.test1 (Detached)
    28210.test2 (Detached)
    12494.moretesting3  (Detached)
    31787.testingfour4  (Detached)
    13192.testscreen5   (Detached)
5 Sockets in /var/run/screen/S-root.

I know I can quit an individual screen with screen -S 12858 -X quit or screen -S test1 -X quit but I need a way to close all the screens at the same time.

Is there an ssh command or bash script that is able to close every open/detached screen?

share|improve this question
up vote 5 down vote accepted

Would a simple killall screen suffice?

share|improve this answer
5 long as you're not on a system where killall is the SysV style tool that literally kills all processes you can kill. (Of course as long as you're not root this will probably have the desired effect - all your screen sessions will be gone :-) – voretaq7 May 27 '13 at 3:22
What if you are root? Is there anything else that would work? – Runner May 28 '13 at 21:52
You can also do kill `pidof screen` – Falcon Momot Jun 19 '13 at 5:33

For that very reason, I recommend using byobu. It's in most Linux Distros' repo's, and it is much easier to have multiple screens open at once and see them all at a glance.

share|improve this answer
This doesn't answer the question. He's asking about how to easily kill off a bunch of detached screen sessions, not about how to have multiple screens open. – EEAA Jun 19 '13 at 3:57
But, using byobu makes this very easy since it will show if you on login if existing / multiple sessions are open, and allow you to kill any/all of them. – senorsmile Jul 1 '13 at 22:43

Your Answer


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.