An URL link has been saved in *.url file via Windows. If you double click the file in Windows, it will open your default browser to the indicated URL. Here is an example of *.url file content:


When the same file is copied on Ubuntu OS, Ubuntu handles it such as a text file. Hence, the browser does not open the URL when double-clicking the file.

My question is: what is the equivalent of *.url file in Linux to make shortcut file for URLs?


4 Answers 4


In Ubuntu an URL shortcut is stored in a .desktop file as follow (for example):

[Desktop Entry]
Name=Link to Best Practices Software engineering

If you still want to open your Windows URL files in Ubuntu, here is described how you can do it:

The Perl script given in that article appears to be broken, but the following code should do the same thing correctly:

# Script to make Microsoft Windows Internet Shortcuts (*.url) work on Linux.

my $browser = 'sensible-browser';  # use the system default browser

while (<>) {
    # match any line of the form "URL = something-without-spaces"
    if (/^\s*URL\s*=\s*(\S+)\s*$/) {
        exec $browser, $1;         # successful exec never returns
        die "$0: could not launch $browser: $!\n";
  • 3
    That Perl script looks broken in several ways: the "filter out carriage return" regexp won't work because it's missing a backslash, and indeed, the earlier regexp in the if clause will never match unless the URL contains the number 1, for the same reason. Also, if it does somehow manage to match, the URL will be passed unescaped to the shell, which is not only a security flaw, but will also break any URLs containing e.g. parameters separated with &. I've submitted an edit suggestion to your answer fixing these issues. Oct 5, 2013 at 11:40

In Unity we have .desktop files for defining items on the launcher, desktop, or other locations. To create these see the following question:

A link to an internet file may have an entry as simple as the following

[Desktop Entry]
Name=Internet Link
Icon=<icon to display>

You can create such a file with a text editor, or much easier by simply dragging and dropping a bookmark from your browser to the desktop.

However keep in mind that such a simple .desktop file will not automatically open the given URL in a browser if the target is e.g a text document, or image. To overcome this see the following question:

In case we do need to open .URL files more often (e.g. from a shared drive) we may also run a bash script similar to this to open them:

#! /bin/bash

# opens Windows URL file submitted as command line argument in browser

source $1
xdg-open $URL

The command not found error from this script can be ignored or sent to /dev/null. If we must then we could associate this script to a Mime type for the extension URL to double click open an URL file.

  • An amazingly simple script when compared to the other answer. Put that into a .desktop file and associate .url files with it then you are done.
    – kiri
    Oct 10, 2013 at 10:06
  • 3
    Simple, but an attack vector. As we are executing/running the first argument (the url file). Jul 9, 2015 at 6:42

You can make your Linux file manager open .URL file in your default browser. This is particularly useful for people who share files between Windows and *nix machines. To do this create a script file let's call it mswin-urlfile (or what ever you like) in /usr/local/bin (or your preferred folder). Change permission: chmod +x /usr/local/bin/mswin-urlfile

if [ "$1" == "" ] || [ "$1" == "--help" ] ; then
  echo "$(basename "$0") URLFILE - opens a .url file in the default browser"
  sed 's/^BASEURL=/URL=/' "$1" | grep -m 1 '^URL=' | sed 's/^URL=//' | sed 's/\r//' | xargs xdg-open

To test use it manually from a shell prompt using:

mswin-urlfile test.url

Next you will need to configure file manager to call mswin-urlfile when opening a .URL file type. This works across all *nix and shells allowing you to open your .URL files from within your file manager. Exactly how to do this depends on the file manager you use. Lookup "file association" for the specific file manager you use.

For example Nautilus file manager is mentioned at 369967 and create a mimetype for the .url extension

Open Applications > System Tools > File Types Editor, and click the New button. Enter the following information in the corresponding tabs:

► General: Category: Text and source code

Name: x-url

Description: Microsoft Internet Explorer Shortcut

You can choose an icon for the .url file-type via the browse button […] – if you don’t have any, there are some at the bottom of this post that you can save to a folder like /home/yourusername/Settings/Icons.

► Filenames:

Filename pattern: *.url

► File contents:

When you click +Add, you’ll see more than one data entry field, but all you need to worry about is the Value: one.

Value: [InternetShortcut]

Now your system knows what .url files are, but it still doesn’t know what to do with them. You now have to associate the .url extension with the executable script fx-url, so right-click any .url file and go to Properties > Open With. Click the Add button, and at the bottom of the “Add Application“ window you’ll see the “Use a custom command“ option; click this, then either browse to /user/bin and select the symlink you created, or enter /usr/bin/Web Shortcut Browser (or the appropriate name if you changed it). Click the Add button to save your changes (but leave the “Properties“ window open as you’ll need it in the next step).

Now you need to make the associated action the default option for double-clicking, otherwise you’ll have to right-click .url files and choose the required option from the context menu. To make opening in Firefox the default action, in the Open With tab of the “Properties“ window, click the dot to the left of the entry you just added (eg: “Web Shortcut Browser“), then click Close.

open any Nautilus (file manager) window and go to Edit > Preferences > Behaviour. In the “Executable Text Files“ section, make sure that “View executable text files when they are opened“ is selected. Click Close, and it is done (you may need to log out or reboot for the changes to take effect). Now when you right-click any .url file, you should see “Open with Web Shortcut Browser“ as the top entry of the context menu, and it will be the default action for double-clicks.

I use a different file manager so I have not tested the above Nautilus instructions.

I prefer to keep using URL files as I use a mixed environment Android + app to open or create URL files; Linux + script (above) to open URL files; Windows (built in URL file support). Alternatively, you could convert every system to just use bookmark files and sync them, but builtin browser syncing has messed up my bookmarks more than once. If you use different browsers (eg Chrome, Firefox, Brave) on different system syncing is not simple.


I'm on Lubuntu 18.04 and using a .desktop file with Type=Link and URL didn't work for me. It only shows an error message saying: HTTP Error: Bad Request.

As a workaround, I call my web browser directly with the URL:

[Desktop Entry]
Name=My favorite website
Exec=firefox https://url.com

The problem seems to be with the file manager, in my case PCManFM 1.2.5. It throws a segfault in libfm.so.4.0, as can be seen via dmesg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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