Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to fix a problem with nginx and think that there is an nginx process running on my machine. When I run this command I get this output.

$ ps aux -P | grep nginx
1000      3947  0.0  0.0  13596   932 pts/0    S+   14:05   0:00 grep --color=auto nginx

But if I try to kill processes 1000, 3947, 13596 or 932 I get errors like:

bash: kill: (1000) - No such process

What's going on? How do I find and kill the nginx process?

share|improve this question

4 Answers 4

ps aux -P shows these columns:

$ ps aux -P | head -1

Only the 2nd column is the pid.

Warning: don't try to kill random pids.

pid 3947 was the grep process that ended when you got your prompt back, so there truly is no such process.

If there was an nginx process, you would have seen it in the grep output. Conclusion: nginx is not running on your machine.

share|improve this answer

I usually find pgrep more convenient than ps | grep. You might also want to look at killall if the end goal is blasting a bunch of processes by name.

share|improve this answer
+1 I prefer it, too. I guess you don't see it around much because it relies on having /proc, so it's less portable than a vanilla ps | grep. –  Joseph R. Aug 13 '14 at 22:16

But if I try to kill processes 1000, 3947, 13596 or 932 I get errors like [...]

in the output of ps, 1000 is the user ID of the process (grep in that case), 3947 is the PID of grep, and the other numbers are status parameter values and not at all PIDs.

If you want to see all processes by name, then use something like

ps -lfC nginx

caveat: you have to know the exact name, otherwise ps doesn't return anything. If you don't know the exact name, then use pgrep.

share|improve this answer

A common trick to avoid the grep command itself from showing up in ps output is to put the first character in a character class so that it won't match its literal self. I.e.,

$ ps aux | grep [n]ginx

This way the grep pattern will match "nginx" but not the literal "[n]ginx" that shows up in the ps output.

share|improve this answer

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.