How to launch a GUI-based desktop program from command line in Linux

Last updated on October 1, 2020 by Dan Nanni

If you often use a particular GUI program in your desktop environment, it may be cumbersome to launch the program by navigating desktop menus which may be several mouse clicks away.

To speed things up, you can create shortcuts to your favorite programs inside Application Launcher (e.g., Ubuntu Desktop). Alternatively, you can use a command line interface (CLI), and start GUI programs from terminals, especially if you spend most of your time in terminal windows.

In this tutorial, I will explain how to launch a GUI program from the command line. This guide is written for GNOME desktop, but it should be applicable to other Linux desktop environments.

In order to run a GUI application from a terminal window, the main question is how to find out the name of an executable that corresponds to the GUI application.

Each GUI application has a corresponding .desktop file which contains information about the application (including application name and a name of an executable, icon, etc).

In GNOME desktop, .desktop files for system-wide GUI software are stored in /usr/share/applications directory. Meanwhile, .desktop files for GUI programs that are installed on per-user basis is stored in ~/.local/share/applications folder.

To identify the name of an executable from .desktop files, first check the exact name of a GUI application, from the title bar of the application.

For example, the system settings application for mouse and touchpad is shown below. According to its title bar, the name of this application is Mouse and Touchpad.

Once you have obtained the name of a GUI application, find a .desktop file that contains the name by running the following command. In this example, the .desktop file is located at /usr/share/applications/gnome-mouse-panel.desktop.

$ find /usr/share/applications ~/.local/share/applications -name "*.desktop" | xargs grep "Mouse and Touchpad"
/usr/share/applications/gnome-mouse-panel.desktop:Name=Mouse and Touchpad

The name of an executable can be found in Exec=xxxxxxx line of the .desktop file. In this example, the executable is gnome-control-center mouse.

$ cat /usr/share/applications/gnome-mouse-panel.desktop
[Desktop Entry]
Name=Mouse and Touchpad
Comment=Set your mouse and touchpad preferences
Exec=gnome-control-center mouse
Icon=input-mouse
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;

To launch the GUI-application from CLI, simply type the executable and press enter from the terminal.

$ gnome-control-center mouse

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean