How to Open .URL files in Ubuntu Linux
If you’re using Ubuntu and want to open .URL links (from windows), they won’t open by default.
You have to do some steps to get them working.
I’m using chrome so I first had to link chrome into bin firefox was already linked
ln -s /opt/google/chrome/chrome /usr/bin/chrome
You need to install the Thunar file manager
sudo apt install thunar
Here are the further steps:
-
Right-click a .URL file
- Select: “Open With”
- “Open With Other Application”
- Select on “Use a custom command”
-
Copy the following command to the text-field:
bash -c "cat %f | grep URL | cut -d'=' -f2 | xargs chrome &" -
Click the default checkbox, then press Open. Your URL-Links will now open in Chrome.
Since every distribution / version seems to have different issues.. I’ve added your additions below. Thanks for interacting. That’s exactly the spirit of this articles.. providing solutions to weird issues.
Comments
bee (14. June 2019) It should be -f2- and not -f2 in case the URL has ”=”
pg0 (3. April 2020)
my .URL file content look like this:
[InternetShortcut]
URL=http://patrickgawron.com/
I have just installed my version on another ubuntu 18.04.1 and it worked fine
farialima (22. November 2019)
and it should be grep -e '^URL=' in case there’s URL in the URL
Brian (26. January 2020) Problem with this Ubuntu/Linux world, so much assumption and so much understood. You indicate “Right-click a .URL file”…but WHERE??? In a browser, in terminal?
pg0 (3. April 2020) some_site.URL is usually a file. If you want to open a file, you have to do so on your desktop or in some filemanager.
Rob Ernster (7. May 2020) After making the two suggested corrections above and some trial and error, just removing chrome from the command works with Firefox. This is the edited for Firefox command that works for me:
bash -c "cat %f | grep-e '^URL' | cut -d'=' -f2- | xargs &"
Also, clicking [Open] after entering the command does not open the link. You have double click on the link in your File Manager.
emkura (25. September 2020) What if i don’t have “Use a custom command” option in the open with dialog on Linux 18.04 LTS?
Uwe (14. December 2020) I’m using KDE and firefox as my main browser. I wrote a shell script I’m calling from Dolphin:
#!/bin/bash
grep URL "$1" | cut -d'=' -f2 | xargs /usr/bin/sensible-browser &
sensible-browser uses the current system default so it’s easy to switch between chromium and Firefox.
Daniel (2. March 2021) Optionally, you can just install url-open. It’s a small program that enables you to double-click on a URL file in any file manger and have it open in your default web browser.