What's the terminal command for finding out a process's id

I want to exit a process using the command line, but I can't recall the command to look up the process's ID. Does anyone know it?


The command to find out a process's id (given its name) is pidof. However since your intention is to kill the process, there are better/easier ways than using pidof to find its pid first:

Assuming the process you want to kill is uniquely identified by its name (or you want to kill all the processes with that name), you don't need to know its pid. You can simply do killall processname.

If there are multiple processes with the same name, but you only want to kill one of them, using pidof won't help you much, because it will give you the pids, but it won't give you any information to determine which of the pids belongs to the process you actually want to kill.

In this case you can do ps aux | grep processname which will shows all processes with the given name as well as the console they're running on (if applicable) and the arguments they were invoked with, which hopefully allows you to identify the process you're looking for.

If the process opened any X-windows, you can also use xkill to kill (invoke xkill and then click on the window).


You should have a look at pgrep and pkill, two very handy and powerful utilities that are found on most Linux and UNIX systems.

$ apropos pgrep
pgrep (1) - look up or signal processes based on name and other attributes