Tutorial: Create desktop shortcut on Linux (practical example)

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
3,968
Reaction score
4,157
Credits
32,446
What?

In this tutorial we'll be creating a desktop shortcut (aka. *.desktop file) which will point to some item of interest such as installed documentation or web site link etc.

Motivation

There is plenty of useful documentation already installed on your Linux system, the default directory location is /usr/share/doc,
however finding what you need in that directory is cumbersome, because you have to visit it every time you want to read and then also search for the right file.
This means a lot of people likely don't even bother to read installed documentation that could otherwise help them a lot to master Linux.

On another side your Desktop most likely sits empty and unused without any shortcuts.

An elegant solution therefore is to create some links to documentation of interest and set up a nice icon, so you kill two flees with one shot:
  • Put your Desktop to use
  • Make valueable documentation of interest right in front of you and easy to access with simple double click.
Here are few such sample desktop shortcuts on my Desktop, which open specific documentation I'm currently interested in to study, so I made shortcuts with icon:

icons.png


How to create these desktop shortcuts?

First step is to find the documentation, for the purpose of this tutorial we'll be creating a shortcut to Linux PAM documentation which is about Pluggable Authentication Modules.
(but you feel free to modify this to link to any docs you want located in /usr/share/doc

Linux PAM documentation is likely not installed by default so go ahead and install it, on Debian or Debian based distro the command is as follows (change it for your distro as applicable):
Bash:
sudo apt install libpam-doc

This will install Linux PAM documentation into /usr/share/doc/libpam-doc
HTML index file is called index.html and you can find it in /usr/share/doc/libpam-doc/html/index.html
We need to create a link to index.html in order to simply browse entire documentation in web browser by clicking on the nice shortcut.

We also need an icon for the shortcut, you can get the one from the screenshot above from this website link:

On download page choose 64 pixel size and download it to your Pictures directory.
If you don't like the icon choose another one:

Now that we have all we need, next step is to run the following command to actually create the shortcut:
Bash:
nano ~/Desktop/Linux-PAM.desktop

When nano editor opens enter the following configuration and make sure to update links to documentation and icon file as needed:

INI:
[Desktop Entry]
# 3 types of desktop entries: Application, Link and Directory
Type=Link
# Specific name of the application
Name=Linux-PAM
# Icon to display in file manager, menus, etc
Icon=/home/YOUR_USERNAME/Pictures/folders-64.png
# Tooltip for the entry
Comment=The Linux-PAM Guides
# If entry is Link type, the URL to access.
URL=/usr/share/doc/libpam-doc/html/index.html

Once you're done press CTRL + O followed by CTRL + X to save and close the file.

The shortcut with the icon should appear on your desktop, double click it to open.

---

Make sure to create as many shortcuts as possible this way on your desktop to link to documentation to put your Desktop to use.
You can also modify above template to create links to web pages or favorite directories or files instead of documentation, it's up to you what kind of shortcuts you'll create.
 
Last edited:


Follow Linux.org

Members online


Top