How to find the program name of a shortcut?
I have installed some apps through the Ubuntu Software center. How can I find the corresponding terminal command? For many apps, this is not the same as the displayed name. For example, the app called Text Editor can also be launched by typing "gedit" in the terminal, but how can I find this for other apps?
Solution 1:
Generally apropos
will be of help.
For example, apropos 'text editor'
gives me
ed (1) - line-oriented text editor
ex (1) - Vi IMproved, a programmer's text editor
gedit (1) - text editor for the GNOME Desktop
gnome-text-editor (1) - text editor for the GNOME Desktop
red (1) - line-oriented text editor
rview (1) - Vi IMproved, a programmer's text editor
rvim (1) - Vi IMproved, a programmer's text editor
vi (1) - Vi IMproved, a programmer's text editor
view (1) - Vi IMproved, a programmer's text editor
vim (1) - Vi IMproved, a programmer's text editor
xedit (1) - simple text editor for X
Solution 2:
For most desktop launcher icons, in at least MATE, KDE Plasma/Neon, and probably other DTEs, you can right click on the icon and select Properties in the menu. One of the entries in the properties dialog that appears will be the command line that launcher uses.
Solution 3:
You can navigate the directory /usr/share/applications/
, you will find the shortcuts of many applications, the files appname.desktop
.
You can cat
those files and search for the entry Exec
. Example:
ls -l /usr/share/applications | grep thunderbird
thunderbird.desktop
cat thunderbird.desktop | grep Exec
Exec=/usr/bin/thunderbird %u
In your example, you could type
So /usr/bin/thunderbird
is the command.
You can also try, as @pLumo suggest, search for keywords:
grep -ri "GenericaName=*text*\|Name=*text*"
org.gnome.gedit.desktop:Name=Text Editor
vim.desktop:GenericName=Text Editor
but is trickier because you have to guess what could be the the keywords.
Solution 4:
Method 1
If you know the name of the application as displayed on its window or on its icon, then the following command will show you the path(s) of the executable that "starts" that application:
grep -i "^ *Exec=" $(grep -ril "^ *Name=.*firefox" \
/usr/share/applications $HOME/.local/share/applications) /dev/null
Here firefox is the (partial) application name. In your case, assuming you are searching for the command line of the application called (exactly) Text Editor, then use this:
grep -i "^ *Exec=" $(grep -ril "^ *Name=Text Editor" \
/usr/share/applications $HOME/.local/share/applications) /dev/null
For more detailed information, you can inspect the contents of the .desktop
file(s) displayed in the grep
output.
Method 2
If you had already started the application and it is running on its own window, then enter the following command in a terminal:
ps --no-headers -p $(xprop _NET_WM_PID | cut -f2 -d=) -o cmd
and after that, click on the window you want to learn the command it was started.
This will show the command line (together with any command-line parameters) of the process displaying that window, which may not be necessarily the same as the command that was executed when you initially clicked on the icon to start the application that displayed that window.