Ora

How to Add a Shortcut to Your Desktop in Ubuntu

Published in Ubuntu Desktop Shortcuts 5 mins read

Adding a shortcut to your desktop in Ubuntu is a straightforward process, primarily achieved by utilizing the Nautilus file manager to manage .desktop files. This allows you to quickly launch your favorite applications or access frequently used files and web links directly from your desktop.

The Easiest Way: Dragging .desktop Files with Nautilus

The most common and simplest method to add an application shortcut to your Ubuntu desktop involves locating the application's .desktop file and dragging it to your ~/Desktop folder. These files are essentially text files that describe how to launch an application, including its name, icon, and the command to execute.

Step-by-Step Guide

Follow these steps to create an application shortcut on your desktop:

  1. Open Nautilus (Files): Click on the "Files" icon in your Ubuntu Dock, or press Super (Windows key) and type "Files" to open the Nautilus file manager.
  2. Navigate to Application Directory:
    • For most system-wide applications, navigate to /usr/share/applications. You can do this by clicking "Other Locations" in the sidebar, then "Computer," and then browsing to usr/share/applications.
    • Alternatively, you can press Ctrl+L in Nautilus to type the path directly.
  3. Locate the .desktop File: Browse through the directory to find the .desktop file for the application you wish to shortcut. For example, for Firefox, you would look for firefox.desktop.
  4. Drag and Drop to Desktop:
    • Once you find the desired .desktop file, click and drag it directly from the /usr/share/applications folder to your ~/Desktop folder (you might see your actual desktop behind the file manager window, or you can drag it to the "Desktop" entry in the Nautilus sidebar).
    • A copy of the .desktop file will be created on your desktop.
  5. Make the Shortcut Executable (Allow Launching):
    • After placing the .desktop file on your desktop, it might appear as a generic icon or plain text. To make it functional, right-click on the newly created shortcut.
    • From the context menu, select "Allow Launching" or "Trust and Launch".
    • The icon should now change to the application's proper icon, and you can double-click it to launch the application.

Common .desktop File Locations

Understanding where .desktop files are stored can help you find them more easily:

Location Purpose
/usr/share/applications Contains .desktop files for applications installed system-wide (for all users).
~/.local/share/applications Stores .desktop files for applications installed by the current user or custom launchers created by the user.
/var/lib/snapd/desktop/applications Contains .desktop files for applications installed via Snap packages.

Creating a Custom Desktop Launcher (Advanced)

If you need a shortcut for a custom script, a specific executable, or a web link that doesn't have an existing .desktop file, you can create one manually. This provides greater flexibility.

Step-by-Step for Custom Launcher:

  1. Open a Text Editor: Launch a text editor like Gedit or Nano.

  2. Create a New .desktop File: Paste the following template into the editor:

    [Desktop Entry]
    Version=1.0
    Name=My Custom App
    Comment=A brief description of my custom application or script
    Exec=/path/to/your/executable/or/script %U
    Icon=/path/to/your/icon.png
    Terminal=false
    Type=Application
    Categories=Utility;
  3. Customize the Fields:

    • Name: The name that will appear under the shortcut icon.
    • Comment: A tooltip description when hovering over the icon.
    • Exec: The full path to the command, executable, or script you want to run. If it's a script, ensure it has execute permissions (chmod +x /path/to/script.sh).
    • Icon: The full path to an image file (e.g., .png, .svg) to be used as the shortcut's icon. You can also use a standard icon name (e.g., firefox, gnome-terminal) if it's available in your system's icon themes.
    • Terminal: Set to true if your command needs to run in a terminal window (e.g., a CLI script), otherwise false.
    • Type: Usually Application. For a web link, you might use Link and set Exec to xdg-open https://www.example.com.
    • Categories: Helps in organizing the application in menus (optional).
  4. Save the File: Save the file with a .desktop extension (e.g., my-custom-app.desktop) directly into your ~/Desktop folder.

  5. Allow Launching: Right-click on your new .desktop file on the desktop and select "Allow Launching" to make it functional.

Example for a Web Link Shortcut:

[Desktop Entry]
Version=1.0
Name=Google Search
Comment=Quick access to Google Search
Exec=xdg-open https://www.google.com
Icon=web-browser
Terminal=false
Type=Application
Categories=Network;WebBrowser;

Save this as google-search.desktop on your desktop, then "Allow Launching."

Troubleshooting Tips

  • Shortcut not appearing or not working: Ensure the .desktop file is in your ~/Desktop folder and you have selected "Allow Launching." Check the Exec path for correctness and permissions.
  • Icon not showing: Verify the Icon path is correct and the image file exists, or that the icon name is valid within your system's icon themes.
  • Permissions: If you're creating a custom script, ensure it has execute permissions (chmod +x /path/to/your/script.sh).

Creating desktop shortcuts in Ubuntu streamlines your workflow, providing instant access to your essential applications and resources.