3

I would like Ubuntu to automatically use the Tor Browser as its default browser. As it launches from the script start-tor-browser and is perhaps not truly "installed" in the same way as Firefox or Chrome, I can't figure out how to do so even after looking at these relevant answers:

How can I set the Tor Browser as my default browser in Ubuntu and open the appropriate files as "New Window"s in Tor Browser even if the Tor Browser is already up, running, and connected?

Ubuntu 14.04

1
  • I've tried all the procedures stated up, but the default web browser remains firefox and not tor
    – Fabrizio
    Feb 21, 2020 at 6:41

3 Answers 3

3

System-wide change

The default browser is determined by the x-www-browser alternative.

In order to add the Tor browser to the list of available options, you have to run this command:

sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /path/to/torbrowser/executable 1

Then, you need to select it as the default by using

sudo update-alternatives --config x-www-browser

You may also do the same for gnome-www-browser as well.

Note that this is a system-wide change. If you're looking to change it for just your user, let me know.


Change for a single user only

In order to set this is the default for a single user, a little more work may be required (but not much).

gedit ~/.local/share/applications/torbrowser.desktop

Paste the following into the file and save (be sure to use the real path of the Tor browser script):

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Icon[en_US]=browser
Name[en_US]=Tor Browser
Exec=/path/to/tor/browser
Name=Tor Browser
Icon=browser

Then, execute the command:

xdg-settings set default-web-browser torbrowser.desktop
9
  • Terminal returns: update-alternatives: --install needs <link> <name> <path> <priority> and must use different command: sudo update-alternatives --install /usr/bin/x-www-browser x-www-browser /path/to/torbrowser/executable [integer like 1, 2, 3, ..]. Nonetheless, this command (followed by sudo update-alternatives --config x-www-browser) still opens Firefox perhaps because running the executable script would try to launch a completely new Tor Network connection/interface rather than simply opening a "New Window" if the browser is already open and running.
    – jtd
    Oct 27, 2014 at 19:46
  • Did you try the gnome-www-browser variant as well?
    – Chuck R
    Oct 27, 2014 at 19:46
  • Sorry, fixed the command (just add a 1 to the end)
    – Chuck R
    Oct 27, 2014 at 19:48
  • Yes, both x-www-browser and gnome-www-browser are pointing to executable script (Selection: 1, Priority: 1, Status: manual mode) and Ubuntu opens new standard Firefox application and Window rather than "New Window" within Tor Browser. Firefox has two entries at Selection: 0, Priority: 40, and Status: auto mode and Selection: 2, Priority: 40, and Status: manual mode
    – jtd
    Oct 27, 2014 at 19:57
  • If when you run sudo udpate-alternatives --config x-www-browser the "Path" column says /usr/bin/firefox, then that's not the correct one to select. There should be an entry for /path/to/start-tor-browser (wherever that file is). That is the purpose of the update-alternatives --install command. The command I had in there originally was malformed, but I've fixed it. It wouldn't have added it the first time because the command was wrong. So, try the update-alernatives --instal... command again with what I have up there (be sure to replace the path correctly). Then --config should work
    – Chuck R
    Oct 27, 2014 at 20:05
2

This approach sets Tor Browser as default browser for a single user. It also makes Tor Browser open a new tab when a link is opened from the operating system.

As a single script

This script should have the same effect as manually following the instructions below it. For execution it needs the environment variable TOR_BROWSER_PATH set to your PATH/TO/tor-browser_LANG.

#!/bin/bash

set -e
set -x

mkdir -p ~/.local/share/applications

cat > ~/.local/share/applications/torbrowser.desktop << EOF
[Desktop Entry]
Type=Application
Name=Tor Browser
GenericName=Web Browser
Comment=Tor Browser is +1 for privacy and -1 for mass surveillance
Categories=Network;WebBrowser;Security;
Exec=$(realpath "$TOR_BROWSER_PATH")/Browser/start-tor-browser --detach --allow-remote %u
Icon=$(realpath "$TOR_BROWSER_PATH")/Browser/browser/chrome/icons/default/default128.png
StartupWMClass=Tor Browser
MimeType=x-scheme-handler/unknown;x-scheme-handler/about;x-scheme-handler/https;x-scheme-handler/http;text/html;
EOF

update-desktop-database ~/.local/share/applications
xdg-settings set default-web-browser torbrowser.desktop
mkdir -p ~/.local/bin

cat > ~/.local/bin/firefox << 'EOF'
#!/bin/bash

/usr/bin/firefox --no-remote "$@"
EOF

chmod u+x ~/.local/bin/firefox
if ! (echo "$PATH" | tr ":" "\n" | grep ~/.local/bin); then

cat >> ~/.profile << 'EOF'

if [ -d "$HOME/.local/bin" ] ; then
  PATH="$HOME/.local/bin:$PATH"
fi
EOF

fi

You may need to log out and log in from your Linux to make the settings apply.

Manual configuration

Set up Tor Browser

Open up the terminal application. Then type or copy&paste the following commands into the terminal:

mkdir -p ~/.local/share/applications
gedit ~/.local/share/applications/torbrowser.desktop

Insert the following into the editor which opened up:

[Desktop Entry]
Type=Application
Name=Tor Browser
GenericName=Web Browser
Comment=Tor Browser is +1 for privacy and -1 for mass surveillance
Categories=Network;WebBrowser;Security;
Exec=PATH/TO/tor-browser_LANG/Browser/start-tor-browser --detach --allow-remote %u
Icon=PATH/TO/tor-browser_LANG/Browser/browser/chrome/icons/default/default128.png
StartupWMClass=Tor Browser
MimeType=x-scheme-handler/unknown;x-scheme-handler/about;x-scheme-handler/https;x-scheme-handler/http;text/html;

Replace PATH/TO/tor-browser_LANG by the appropriate path.

Save the file and close the editor. Then run the following commands in the Terminal:

update-desktop-database ~/.local/share/applications
xdg-settings set default-web-browser torbrowser.desktop

Finished! You should now have Tor Browser in your launcher menu.

Try to open a link from the Terminal with the following command. It should now open in Tor Browser. Make sure no other standard-Firefox windows are open before.

xdg-open "https://askubuntu.com"

Coexistence with standard Firefox

As Tor Browser uses a modified Firefox under the hood, and Firefox tries to run as a single instance, links could now open in an already running Firefox instance instead of Tor Browser. To work around this, we need to ask the standard Firefox to not accept remote commands.

In the terminal, run these commands:

mkdir -p ~/.local/bin
gedit ~/.local/bin/firefox

Paste this into the editor:

#!/bin/bash

/usr/bin/firefox --no-remote "$@"

Save and close, then run these commands:

chmod u+x ~/.local/bin/firefox
echo "$PATH" | tr ":" "\n" | grep ~/.local/bin

If the last command did have a (bold red) line containing .local/bin as output, you have finished here. If not, run the following:

gedit ~/.profile

Add this to the end of the file, save, and close:

if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

You may need to log out and log in from your Linux to make the settings apply.

The only restriction I found with this approach is, that it is not possible to open new tabs in a running standard Firefox instance from outside of Firefox then.

System-wide installation

System-wide installation of Tor Browser is not recommended for privacy reasons (not quite sure).

1
  • @Fabrizio Could you please try that out?
    – jimex
    May 21, 2020 at 12:34
0

I'm using Ubuntu 17.10. Tried many ways but none of them worked. Finally found the solution.

Go to System settings > details > default applications and select the default apps to be used by the system.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .