My girlfriend's cat was walking on my laptop, and I didn't notice her. When I turned to check, I see that I have 32 "Archive Manager" tabs. How can I close them all instantly, as if using Alt+F4 on all of them at once.


From command line:

killall file-roller

You can do alt+f4 but you need to do that for every archive manager that was opened.

  • 21
    Though some might argue that the "killall" command is a bit heavy-handed, yours is still a much more humane solution than the kill cat action I was going to suggest. – Nick Weinberg Apr 23 '17 at 18:20
  • I don't think there is an easier way to stop them all. Lots of alt+f4's would do it to but that was not the question ;-) – Rinzwind Apr 23 '17 at 18:34
  • 5
    @NickWeinberg I appreciate it :) – cat Apr 23 '17 at 22:15
  • 5
    I read this question and answer wrong. I thought it was about the cat had closed all, and that OP didn't know how the cat did it. I was amazed that the cat was able to write killall file-roller :D – Viktor Mellgren Apr 24 '17 at 7:31
  • 1
    damn @ViktorMellgren stop making me spil coffee on my screen – Rinzwind Apr 24 '17 at 9:20

Another approach would be to use the wmctrl utility (Window Manager control). This can be used to tell the window manager to pretend you clicked the close button. This avoids the potentially heavy-handed nature of killall; for example, some programs with an unsaved document will immediately exit when they are killed (even gently), while clicking the close button brings up a "Do you wish to save?" prompt.

The basic command is wmctrl -c WINDOWTITLE, so in this case wmctrl -c "Archive Manager" (assuming it has no open file: that changes the title). Unfortunately, it only closes one at a time, so we need to do more to close all of them.

wmctrl returns success if it finds a match, so we can loop until it fails:

while wmctrl -c "Archive Manager"; do sleep 0.1; done

This always chooses the first window it finds, so we need to sleep for a bit to avoid continuously sending a stream of close commands to the first window that's already busy closing - that can cause an error which stops the loop.

This is simple and usually works, but sleeping a set amount of time and hoping a window closes before we try again is a messy and slow way to avoid the error. What we really want to do is to immediately send one close message to every matching window.

We can find all open windows with wmctrl -l. This lists a numeric window id that we can use to identify each window individually, even if they all have the same title. Then we need to filter to only the matching windows (the grep command), pull out just the window id (the cut command) and call wmctrl -i -c for each one. The -i is needed to match the window id instead of the window title.

for w in $(wmctrl -l | grep "Archive Manager" | cut -d" " -f1); do
    wmctrl -i -c $w

A bit complicated for just typing in whenever a cat steps on your keyboard, but hopefully a handy technique to keep in your scripting toolbox.

  • 2
    So you expect the cat to type something worth saving? – Rinzwind Apr 24 '17 at 9:21

You can use the Ctrl+Q keyboard shortcut which will close all opened windows of Archive Manager.

The Ctrl+Q shortcut is common on Ubuntu (and lots of other distributions as well). It works the same with most of the applications I've used thus far. That is, it will close all windows of a running application.

  • Undone my vote, since I can't confirm that Ctrl+Q actually does that. While the Quit menu did close all opened windows of Archive Manager, the shortcut key did not do the same (at least in 14.04). – user37165 Apr 24 '17 at 12:52
  • 1
    @clearkimura I cannot confirm if it's due to the fact that I'm using gnome, or if it's because of the Ubuntu version, but it works for me on Ubuntu 17.04 (with gnome) which uses Archive Manager version 3.22.3 – Dan Apr 24 '17 at 13:16

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.