Linux – If I know the PID number of a process, how can I get its name

linuxpidprocessshellunix

If I have the PID number for a process (on a UNIX machine), how can I find out the name of its associated process?

What do I have to do?

Best Answer

On all POSIX-compliant systems, and with Linux, you can use ps:

ps -p 1337 -o comm=

Here, the process is selected by its PID with -p. The -o option specifies the output format, comm meaning the command name.

For the full command, not just the name of the program, use:

ps -p 1337 -o command

See also: ps – The Open Group Base Specifications Issue 6

Related Question