How to add desktop icons on CentOS 7

For the most part, I prefer to work using the terminal on a minimal install of Linux; however, there are those occasional times where the GUI is necessary.  Recently faced with having to add a few desktop shortcuts to the Desktop posed a bit of a problem for me. Basically, wanted to achieve two things, a Desktop icon to launch a script and a link (symbolic) to a directory on the system.

To create a Desktop icon using terminal, I created a file like this, with the name helloworld.desktop on the ~/Desktop with 755 permissions.   Note the Icon is optional, you can remove it.

helloworld.desktop

[Desktop Entry]
Exec=/root/helloworld.sh
Icon=/root/helloworld.png
Type=Application
MimeType=text/plain;
Terminal=true
Name[en_US]=Hello\n World
Comment[en_US.UTF-8]=Hello World
GenericName[en_US.UTF-8]=This is actually the Description, Hello World

Change permissions

chmod ~/Desktop/helloworld.desktop

Done.

To create a link to the desired directory.

ln -s /mnt/mydirectory ~/Desktop/ 

Done.

That’s it.  Couldn’t be easier.