cancel
Showing results for 
Search instead for 
Did you mean: 
Trevor
Commander Commander
Commander
  • 365 Views

Name of Process

If I know the PID of a process, I can retrieve the name of the process, using the following command:

ps  -p  <PID>  -o  comm=

where
-   <PID> is the process ID/number
-   comm=    a format specifier, which essentially refers to the command (i.e. name of the process)

 

Another crude way of achieving this same output is using the following construct:

top  -b  -n1  -p <PID>  |  tail -1  |  awk '{ print $NF}'

Note:  I'll leave it to you to peruse the man page of the top command to see what the -b and -n options are all about.  I don't want to leave some fun for you

 

Got any other methods to retrieve the name of the process, when the PID is known?

 

 

 

Trevor "Red Hat Evangelist" Chandler
Labels (3)
3 Replies
Blue_bird
Starfighter Starfighter
Starfighter
  • 340 Views

Nice information..!

Thanks for sharing..!!

0 Kudos
Blue_bird
Starfighter Starfighter
Starfighter
  • 340 Views

the other methods are:

ps -fp <PID> and ls -l /proc/<PID>/exe

Blue_bird_0-1745048432833.png

Thanks

Trevor
Commander Commander
Commander
  • 331 Views

Very nice addition to the methods that will achieve this!

Trevor "Red Hat Evangelist" Chandler
Join the discussion
You must log in to join this conversation.