0

I want to get the PID of running program via the terminal. I searched here and in Google and I didn't find how I can do that. Which command will give me the PID of running process(es)?

0

4 Answers 4

5
pidof <insert process name>

ex:

user@localhost:~$ pidof firefox
31838
1

$$ shows PID of script, which is running.

    echo $$

Also for C/C++ see http://linux.die.net/man/2/getpid .

1

Consider using the top command in terminal.

   The  top  program  provides  a dynamic real-time view of a running
   system.  It can display system summary information as  well  as  a
   list  of processes or threads currently being managed by the Linux
   kernel.  The types of system summary  information  shown  and  the
   types,  order  and size of information displayed for processes are
   all user configurable and that configuration can be  made  persis‐
   tent across restarts.

via man top

1

get all pids :

$ ps -A -o pid

get app pid :

$ pidof <app name>

get app name from pid :

$ ps -p pidnumber -o comm=

image demo

Not the answer you're looking for? Browse other questions tagged .