I'm trying to create a desktop shortcut that starts File Manager at a specified directory, in this case a mounted USB drive.

Here's what I have so far:


[Desktop Entry]
Comment=Backup Drive
Exec=/usr/bin/pcmanfm /mnt/elements

But this shows up on the desktop as a regular text file named Backup.desktop, and when it's double-clicked it opens in LeafPad.

None of the advice I'm finding addresses these two important issues.

How can I fix this so that it appears as a normal shortcut and runs File Manager?


Per Roger's request in the comments, here's the ls output:

pi@OFFSITE:~ $ ls -l ~/Desktop/Backup.*
-rw-r--r-- 1 pi pi 202 Jul 19 18:46 /home/pi/Desktop/Backup.desktop
  • It might help if you explained what your project is not just the part you are stuck on. For example, are you trying to automate a backup? if so there are several better methods than trying to automate a GUI Jul 20, 2020 at 2:36
  • The backup is automated elsewhere—the rPI is the backup's target (via Samba). I'd like to be able to double-click a desktop shortcut and have File Manager open at the mounted drive so I can quickly and easily inspect its contents from time to time.
    – InteXX
    Jul 20, 2020 at 2:48
  • 1
    Might the file be called Backup.desktop.txt with the "txt" extension being "hidden" on the GUI? This would explain the behaviour you are describing. Try adding the output from ls -l ~/Desktop/Backup.* to your question. Jul 20, 2020 at 9:28
  • 1
    I added the output. I don't know exactly why it's working now, but maybe it's because I signed out and back in in the meantime. I turned off the execution prompt in File Manager's preferences, and all seems well. | @RogerJones
    – InteXX
    Jul 20, 2020 at 17:37

2 Answers 2


I created backup.desktop in /home/pi/Desktop with the code you posted above. I only changed the folder name from /mnt/elements to /home/pi/Test (since I do not have a /mnt/elements, you will need to make sure whichever folder you use exists and is available when running the script - e.g. that the drive is connected to the Pi). It ran just fine when clicked, but did prompt me to execute, execute in terminal, open, or cancel the operation (see below for how to avoid this and the caveats in doing so).

You can also add a custom icon, by adding the following line to your backup.desktop file:


for example:


Alternatively, you can create a simple shell script to do this.

using your favorite editor create the shell script:

nano open_filemanager.sh

add the following code:

#!/usr/bin/env bash

/usr/bin/pcmanfm /mnt/elements

save the script and exit your editor.

Make the script executable:

chmod 744 open_filemanager.sh

Copy the file to the desktop:

cp ./open_filemanager.sh ~/Desktop

You can now double click the script file from the desktop, but you will be prompted whether to open the file or execute it. Choose execute.

This prompt is a security feature, but if you would like to run the script without prompting you can turn it off (note: since you control the script's contents this isn't really an issue for this script, but this will turn the protection off for all executable scripts).

To turn off the prompt:

Open File Manager

Then open the preferences menu (Edit->Preferences)

On the General tab

click "Don't ask options on launch executable file"

Close the preferences dialog and file Maanger.

You should now be able to double click the icon from the desktop with no prompt.

  • Oddly, when I signed in this morning, the filename Backup.desktop was no longer visible and all that was present was the icon. I double-clicked it and received the prompt you described. I turned that off in Preferences, as you suggested, and all is working as expected. It must've been the sign-out/sign-in cycle that did it.
    – InteXX
    Jul 20, 2020 at 17:30

I'm not sure if it's possible to do it via the GUI. Here're the commands for terminal:

cd ~/Desktop
ln -s /path/to/directory LinkName

Here, the ln command creates a symlink (symbolic link) with the name LinkName to the original directory or file, which is like a shortcut. But it actually doesn't open the original directory.

  • Thanks, now I know how to create a symlink in Linux :-)
    – InteXX
    Jul 20, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.