What is the most portable Unix shell

Shell scripting to create a .desktop file for a portable application

Bash Shell Scripting: Create a portable app link.

The term shell used in operating systems refers to the operating system's command interpreter. In general, it is a powerful text interface that manifests itself in the form of a terminal (console) and essentially performs three important work areas: managing the operating system, running applications and interacting with them, and as basic environmental programming. And scripting refers to the technique of designing and creating scripts using a shell.

Shell scripts are extremely useful. It's a good idea to write the requirements that we have and then edit scripts that do that work for us. In this particular case, we will use it to create application links (shortcuts) in the start menu and on the desktop of portable, self-executing, and self-contained apps.



Often times we have downloaded and installed applications that when installed or run are not or are not in the repositories of our GNU / Linux distribution. The corresponding .desktop files are not created in the process by the same, or in the best case, it will not be placed in the correct path, so after refreshing the start menu it will be read and displayed in the list of installed packages of the operating system.

Hence, we have to rely on using applications such as "Alacarte" or "Menulibre" to manually create the corresponding link in the start menu.

And while these graphics applications are very easy to use for this purpose, it is never too much to know Create your own script to perform this operation and know exactly how this operation is performed within the operating system.

If you are unfamiliar with creating and / or using shell scripting files, this is the place to go read this previous post (Shell, Bash and Scripts) Para Empezar and then if necessary, explore all publications on the subject.

Creating the program with shell scripting

For space reasons we assume that we already know how to create a script from scratch, i.e. we already know how to create the header or the first few parts of our script, and we go straight to the contents of the script.

However, when in doubt, check this out Previous post (Building Your Program Step-by-Step Using Shell Scripting - Part 1) to clear up any doubts.


Script content on mousepad


Since you can use the code to analyze and omit the header, the following script automatically performs the following processes:

  1. Check if it is being used as super user root or super user root.
  2. Delete previous links in the application that were created by a previous version.
  3. Create the new desktop file (link) for the application in its own folder at the user's home.
  4. Assign user owner permission to the created file.
  5. Assign the appropriate read / write / execute permissions to the created file.
  6. Create the new symbolic links to the required routes.
  7. Refresh the Start menu to see the .desktop file that was created.
  8. Run a specific url for the application being built.


It is recommended to create this file in the folder that contains the application / executable in question with the icon (picture / logo) indicated in it and that this folder is in the path instead of the route ie.

I hope this little script will enable you to resolve your related needs on the subject! Until the next article.

As I leave you the link on the official Gnome website on the subject and this video: