1

When I issue

ps aux | grep mtp

I get

ubuntu-+ 15934  0.1  0.0 519848  7068 ?        Sl   21:13   0:00 /usr/lib/gvfs/gvfsd-mtp --spawner :1.9 /org/gtk/gvfs/exec_spaw/20

So the PID in this case is 15934. But every new time this is run the PID is different. Is there any other way to kill a process other than by PID?

edwinksl
  • 23,789
Bachalo
  • 753

2 Answers2

2

You can use ps to find the PID of the process, then pass that to kill:

kill $(ps -C /usr/lib/gvfs/gvfsd-mtp -o pid=)

The -C flag specifies a command name to search for in the list of processes, and the -o pid= option means ps will print only the PID. The result is passed as the only argument to kill.

Travis G.
  • 1,877
0

I issued

ps aux | grep mtp

which gave me a few mtp related processes and compared with the camera mounted and unmounted to get the specific process

and then

pkill -9 gvfsd-mtp

does the trick. But the supplied answer above I assume will also work!

muru
  • 197,895
  • 55
  • 485
  • 740
Bachalo
  • 753