Have you created a Desktop shortcut file for your app and want to make it executable and allow launching using the command terminal? Then, here is the way to do that.
Creating a desktop shortcut for a manually installed application on Linux is not easy as we have in Windows. It is because we have to manually mark the created shortcuts executable due to security reasons. Although most of the GUI programs on Linux automatically create the launcher shortcuts, the same is not true for Desktop shortcuts.
For knowledge, the Application launcher shortcut files are placed either in /usr/share/applications
or ~/.local/share/applications
locations. We can copy them directly on Dekstop to create a Desktop shortcuts. However, even after that, we have to right-click and select Allow Launching option to ensure the shortcut can be executable. Most of the time, we do this task using the GUI of Linux. But we can do that using the command terminal as well. Here are the commands to do that:
Copy Shortcut to desktop
First of all copy your created app Shortcut file on your desktop or simply copy the existing shortcuts from /usr/share/applications
or ~/.local/share/applications
locations.
The command for that is:
cp path-to-your-app.desktop ~/Desktop
Note: Replace path-to-your-app.desktop with the actual desktop shortcut file name and path.
If you don’t know how to create desktop shortcuts then see: Create a desktop shortcut for any app in Ubuntu 20.04 LTS
Mark the shortcut status trusted
Now use the given command to let the system know the file is trustable.
gio set ~/Desktop/your-app.desktop metadata::trusted true
Note: Replace your-app.desktop with the shortcut file name
Allow execution
Finally make the desktop shortcut file executable, so that our system can execute it to run the corresponding application under your user rights.
chmod a+x ~/Desktop/your-app.desktop
That’s it your .Desktop file is executable and can be used to run an application with just a double click of your mouse.
Thank you for actually posting useful content.
You’re way ahead of the rest!