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?
Nice information..!
Thanks for sharing..!!
the other methods are:
ps -fp <PID> and ls -l /proc/<PID>/exe
Thanks
Very nice addition to the methods that will achieve this!
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.