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

jtd
  • 2,385

3 Answers3

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
Chuck R
  • 5,038
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).

jimex
  • 21
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.

Zanna
  • 72,312
Lasithds
  • 101