Linux – Where does the command “top” get its information from in linux

linuxpidtop

Which files does the linux command "top" read from in order to build its table of data? Specifically, I'd like to be able to find the data for the "command" column based off of a PID.

Best Answer

It's in /proc/$pid/cmdline. The fields are nul separated. Example on my machine:

$ xargs -0 echo < /proc/4263/cmdline 
/usr/lib64/firefox-3.5.3/firefox -no-remote -P default
$
Related Question