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:
[InternetShortcut]
URL=http://abdennour-insat.blogspot.com/
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?
In Ubuntu an URL shortcut is stored in a .desktop file as follow (for example):
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:
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
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:
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.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
To test use it manually from a shell prompt using:
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
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
andURL
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:
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
.