Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have lots of pdf opened(40-50). I want to close all pdfs at the same time, not one by one.

share|improve this question
    
What program did you use to open them? –  Milan Todorovic Dec 4 '12 at 11:23
    
What desktop environment (Unity, GNOME, KDE)? –  Eric Carvalho Dec 4 '12 at 12:01

2 Answers 2

up vote 3 down vote accepted

You could send a regular kill signal to all instances of the PDF reader application.

First, identify your application name. For GNOME default PDF reader is evince, for KDE this is okular. Now, kill all of those processes you own using pkill, like this:

pkill -u gert evince

To kill all evince processes owned by me (gert).

share|improve this answer

You can use grep to find all the process and kill it using the below command

kill -9 `ps -ef | grep ".pdf" | grep -v grep | awk '{print $2}'`

Hope this helps.

share|improve this answer
    
Why kill with signal 9? Standard signal 15 should be sufficient to close an application. Additionally, you don't need a complicated chain of commands when there's pkill. I suggest to take a look at my answer. –  gertvdijk Dec 4 '12 at 11:48
    
@gertvdijk Yes. 15(SIGTERM) can be used. But here I have used 9(SIGKILL) to kill process and to ignore any File IO operation that can be handled at the kernel level. kill -9 for sure kill :) –  devav2 Dec 4 '12 at 12:07
    
For a simple PDF reader it won't do much damage, but don't make this a habit. It can do serious harm (corruption) when you kill processes uncleanly, similar to cutting the power of your machine without a proper shutdown. –  gertvdijk Dec 4 '12 at 12:10

Your Answer

 
discard

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.