Ubuntu – How to find an application’s command, graphically or otherwise

command line

I often find that I need to figure out the command to execute a certain application, such as an Alarm Clock application or the System Monitor. However, many of the actual CLI commands to run these are not directly evident. What I usually do is just go to the Ubuntu Software Center, then search for the application's "common name" and hence find its package/command name. I would like to know if there is an easier or more efficient way of doing this.

I was wondering if there is a command similar to xprop, where clicking on an open (graphical) application would output its command in the terminal. In other words, I am interested in a graphical way of finding an application's command.

For example, if I run such a command and click on System Monitor, the terminal would output gnome-system-monitor, etc. Thanks.

PS. If a solution is not currently available, I would be interested in writing my own script with this functionality. I only know basic bash, however. I realize that should probably go under a separate question, but I'm just throwing it out there.

Best Answer

I know you prefer a graphical route but here's my effort as a learner of CLI stuff ...

To list names with commands:

grep '^Name=' /usr/share/applications/*.desktop > ~/Desktop/mgtl1.txt && grep -h '^Exec=' /usr/share/applications/*.desktop > ~/Desktop/mgtl2.txt && paste -d':' ~/Desktop/mgtl1.txt ~/Desktop/mgtl2.txt > ~/Desktop/mgtl3.txt && perl -p -i -e 's/\/usr\/share\/applications\///'g ~/Desktop/mgtl3.txt && perl -p -i.bak -e 's/\n/\n\n/'g mgtl3.txt && perl -p -i.bak -e 's/:/\n/'g mgtl3.txt  

will create four files on the desktop and mgtl3.txt will look like this in part:

apport-gtk-mime.desktop  
Name=Report a problem...  
Exec=/usr/share/apport/apport-gtk -c %f

audacity.desktop  
Name=Audacity  
Exec=audacity %F

blueman-manager.desktop  
Name=Bluetooth Manager  
Exec=blueman-manager

To find the command for any software
Launch the software. Then, run

COLUMNS=150 ps -ef > ~/Desktop/out.txt  

Examine the last few lines of out.txt for the relevant command.