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?


Would a simple killall screen suffice?

  • 5
    ...as 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.

  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.