Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

Please see the output of below ps command:

abc@smaug:~/Desktop$ ps ax | grep firefox
 2213 ?        Sl     2:01 /usr/lib/firefox/firefox
 2644 pts/0    S+     0:00 grep --color=auto firefox

Please explain both rows and what process id can be used to kill firefox process?

Process id 2644 keeps on changing everytime I run that command.

share|improve this question
kill -9 2213 will do the job. – Jeight Oct 10 '13 at 16:09
up vote 5 down vote accepted

when trying to find the PID of firefox, you launch a new process the filters the all the unwanted processes. this filter process (grep firefox) also contains the search-term "firefox" and thus finds itself.

whenever you restart ps ax | grep firefox you launch a new grep-process, hence it's PID keeps changing.

So, the short answer is:

use PID 2213 to kill firefox

If you want to get rid of the false positive, you can use another grep to filter it out:

 $ ps ax | grep firefox | grep -v grep

yet another option is to use pgrep (which will only give you the PID of the found processes)

 $ pgrep firefox
share|improve this answer
@uumläute Thank you! – CODError Oct 11 '13 at 5:32

The other answers already explain why you see two mentions of firefox. That's why the way to do what you are attempting is not to parse ps but to use the pkill and pgrep commands:

   pgrep,  pkill  -  look  up  or signal processes based on name and other

For example, to find running instances of firefox:

$ pgrep -l firefox 
1020 firefox

To kill them:

$ pkill firefox
share|improve this answer

The firefox process you have to kill is:

2213 ?        Sl     2:01 /usr/lib/firefox/firefox

The 2644 process is the grep command you are running, which, as you mention correctly, change his ID every time you keep running it.

share|improve this answer


ps aux | grep firefo[x] | awk '{print $2}' | xargs kill
share|improve this answer
Awk and grep is redundant; awk can do pattern matching: awk '/firefox/ {print $2}'... – jasonwryan Dec 27 '15 at 5:31

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.