I'm reading through the .desktop files found in /usr/share/applications and it appears SOME don't share the same process name as the executable file (most do).

Is there a way to find that the process name will be?


Chromes .desktop file

[Desktop Entry]
Name=Google Chrome
Exec=/usr/bin/google-chrome-stable %U

When I run pidof google-chrome-stable it returns null.

But when I run pidof chrome it returns all the PID's

879321 879303 805004 755066 693852 693837 693796 688198 624316 624289 3194 2788 2762 2734 2685 2677 2641 2637 2620 2613 2611 2601

Is there a better way to find the PID?

Please note I MUST search from information found in the .desktop file. (long story)


  • Your question is fuzzy to me. You are stating that same command returns null and a set of PIDs...
    – Ravexina
    Jun 9, 2020 at 20:42
  • Its a typo!! I've changed it Jun 9, 2020 at 20:51

2 Answers 2


It depends on the Exec line, it might be a shell script running another executable or it might be a link or even an executable spawning another.

I'm not sure how you can get the information only from desktop file however one solution might be to run it...

Note that I don't have google-chrome so I use chromium in my example.

# Extract the command from desktop file
$ CMD=$(grep -Po "(?<=^Exec=).+\s" /usr/share/applications/chromium.desktop)
$ echo $CMD

# Run it
$ CMD &

# Get the PID
$ PID=$(echo $!)
$ echo $PID

# Get process name from PID
$ ps --no-header -p $PID -o comm

# Get the complete command line + arguments
ps --no-header -p $PID -o cmd
/usr/lib/chromium/chromium --show-component-extension-options --enable-gpu-rasterization

# Terminate process

What likely happens here is that the initial executable uses an exec...() system call(*) to replace all its code by a new executable and parameters and the very same process id will correspond to that new code and be listed as such by ps, so that the initial executable disappears from the process list. This is often used to set up an environment for another executable.

(*) Or the exec builtin if it is a shell script

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .