7

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?

3
  • This is kind of tricky. I use the command ps -ef | grep hh:mm just after I start the GUI application and try to guess the process name. (Here hh:mm is the hour and minute the GUI application was started.) Mar 3 '20 at 12:39
  • you have the control information files in /var/lib/dpkg/info if you need to understand a package.
    – bac0n
    Mar 4 '20 at 6:11
3

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
1
  • This does find "System Monitor" for example. Mar 3 '20 at 13:39
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.

2
  • 2
    This does not work in gnome. Mar 3 '20 at 13:04
  • Even in Gnome, it is possible to navigate to /usr/share/applications in a file manager, identify the icon by appearance, then open it in a text editor to see the command line and other details. Of course, that's not as easy.
    – jpaugh
    Mar 3 '20 at 21:57
2

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.

2
  • 1
    Like I understand it, OP does not know how to come from the generic name ("Email Client" to the programs name ("thunderbird"), so maybe first grep -r "Email Client" /usr/share/applications.
    – pLumo
    Mar 3 '20 at 13:06
  • @pLumo I updated the question with your insight. Mar 3 '20 at 13:28
2

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.

1
  • 1
    I find it very to do this interactively using gnome-system-monitor. Also, dpkg -L <package-name> | less is another way, provided you already know the name of the package
    – jpaugh
    Mar 3 '20 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.