2

I am trying to get application name by typing a command but it seems like there is no command to get application name from process id. We can only get process name from using process id in command. The command is ps -p <process id> o comm= , which return process name. I want to get application name by using of process id so my query is that: which command I can use to get application name using the process id in Linux?

marked as duplicate by Kiwy, GAD3R, Rui F Ribeiro linux Jun 12 '18 at 12:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • which linux are you using ? – Kiwy Jun 12 '18 at 12:17
3

You could use /proc on recent Linux:

ls -l /proc/[PID]/exe  
#or
readlink /proc/[PID]/exe

This file should be a link to the executable use by this PID.

  • This is working for me on CentOS. I prefer readlink since it outputs only the executable. Thanks. – Kevin Lemaire Jun 12 '18 at 12:37
  • @KevinLemaire it's a matter of taste. It more exploitable I have to agree. You're welcome – Kiwy Jun 12 '18 at 12:38
1

On a platform with a standard procfs with procfs-2 support, you get the result via:

ls -l /proc/<pid>/path/a.out

The file a.out is a symlink to the absolute path of the binary.

Not the answer you're looking for? Browse other questions tagged or ask your own question.