DuckDuckGo from the Terminal

Bangs and Browsers

The main DuckDuckGo search engine offers a very useful feature called bangs. This allows you to search certain websites without using a search engine at all. This is done using a ! plus DuckDuckGo's particular code for that website. For example, if you wanted to search YouTube for videos of cute, fluffy kittens, you'd enter !yt fluffy kittens into the search bar. Searches are run in exactly the same way on ddgr, with only a backslash added (Figure 6), for example:

ddgr \!yt fluffy kittens
Figure 6: Just add a \ in ddgr to use DuckDuckGo bangs just like on the website.

Bangs are available for other mainstream websites, too, such as Wikipedia, Amazon, and even Google itself. If you're not familiar with DuckDuckGo, their blog has a full list of available websites [8].

If you already used a text-based browser, you can pass search results to it from ddgr. This is done using the BROWSER variable. To do this on a one-time basis, just run your search with your browser name, e.g., BROWSER=lynx ddgr lighthouses. For this session, any search results you open in ddgr will be displayed in the Lynx browser (Figure 7).

Figure 7: Search results can be passed to a text-based browser such as Lynx.

This is where the d flag can come in handy, because if you want to keep passing ddgr search results to the browser for this session, you can just enter d with the search term at the omniprompt (e.g., d museums).

If you want ddgr to always pass results to your text-based browser, you'll need to add this to the .bashsrc file and specify its name, for example:

echo export BROWSER=lynx >> ~/.bashrc

Currently ddgr supports ELinks, Links, Lynx, w3m, and www-browser out of the box.

A Word on Tor

DuckDuckGo has a good relationship with the Tor Project, given that their search engine is used by the Tor Browser. The Tor Project said they chose DuckDuckGo because the search engine doesn't log or collect your personal information [9]. DuckDuckGo even has its own Tor hidden service (.onion) address and operates its own Tor exit enclave [10].

In light of this, if you do want to run DuckDuckGo searches over Tor, by far the simplest way is just to download and use the Tor Browser, which also doesn't record any activity and is optimized for your privacy. Still, ddgr does also support searches over Tor, with some extra help. The utility itself can connect to the Internet via an HTTPS proxy. The Tor command-line utility uses a SOCKS5 proxy, so in order to get the two talking, you need to use a non-caching web proxy such as Privoxy.

This isn't too hard to set up. If you're running a Debian-based installation, just open a new terminal instance and enter

sudo apt-get install tor privoxy

Next, configure Privoxy to use Tor by editing /etc/privoxy/config:

sudo nano /etc/privoxy/config

Scroll to the end and add the text

forward-socks4a / localhost:9050 .

Save and exit. You'll next need to restart both Privoxy and Tor for these changes to take effect:

sudo /etc/init.d/privoxy restart
sudo service tor restart

You'll now be the proud owner of a local HTTP proxy using Tor on port 8118. This means you can now use Tor with ddgr with the --proxy parameter to run searches via the Tor network (Figure 8), such as:

ddgr --proxy localhost:8118 lighthouses
Figure 8: Here I've used ddgr with Tor and Privoxy to run a search via the Tor network.

To my disappointment during testing, I wasn't able to use this feature to search within .onion domains such as the address for the New York Times website using the -w flag. This would have been a useful feature, but in fairness, the developer doesn't claim that the utility can access Tor hidden services, just that it can run searches using Tor. Naturally if you want this extra level of privacy, be prepared for much longer search times because your data will be routed through various Tor relays.

DuckDuckGo for It

There's a lot to be said for searching the web via your command line: It's clean, it's quick, and with time, very easy to navigate. You can link parameters together to fine-tune your search results, all without handing your personal information over to the gods of Google.

We've also only touched briefly on the multitude of command-line parameters available in ddgr. There are so many, in fact, that the utility does away with the usual config file because everything is right there in the program. Other features include displaying results in different colors, listing searches in reverse order, and even exporting them in JSON format (presumably for research purposes).

Although ddgr and googler have the same creator, the search engines they represent have very different business models. One is committed to harvesting all your data to serve your targeted advertising; the other might show you the occasional ad but isn't collecting any information in doing so.

Ridding yourself of a conventional browser when searching is also a great way to prevent snoopers who want to "fingerprint" your browser through nefarious methods such as playing sounds or drawing complex, invisible images on your web page. Still, at some point you'll need to open your browser to view these results.

If you're happy to use a text-based browser all the time, you'll be shielded from most of the nastier browser fingerprinting and tracking techniques out there. For those who still prefer a GUI, make sure to check your browser settings to ensure Do Not Track is enabled and use a reliable ad blocker to filter out most malicious URLs. Consider also installing an extension to block third-party/cross-site cookies such as Ghostery [11].

Infos

  1. Android Open Source Project: https://source.android.com/
  2. "Google Fined $57M by Data Protection Watchdog Over GDPR Violations": https://digitalguardian.com/blog/google-fined-57m-data-protection-watchdog-over-gdpr-violations
  3. "Why Should I Use DuckDuckGo Instead of Google?": https://spreadprivacy.com/why-use-duckduckgo-instead-of-google/
  4. "Adding DuckDuckGo to Your Browser": https://help.duckduckgo.com/duckduckgo-help-pages/desktop/adding-duckduckgo-to-your-browser/
  5. jarun (Arun) on GitHub: https://github.com/jarun
  6. Ubuntu man page – xsel: https://manpages.ubuntu.com/manpages/xenial/en/man1/xsel.1x.html
  7. DuckDuckGo parameters: https://help.duckduckgo.com/duckduckgo-help-pages/settings/params/
  8. "DuckDuckGo Bangs – Search Directly On Your Favorite Websites": https://ostechnix.com/duckduckgo-bangs-search-directly-on-your-favorite-websites/
  9. Tor Project – Support: https://support.torproject.org/tbb/tbb-41/
  10. Tor Exit Enclave – DuckDuckGo Help Pages: https://help.duckduckgo.com/privacy/tor-exit-enclave/
  11. Ghostery free ad blocker extension: https://www.ghostery.com/ghostery-ad-blocker

The Author

Nate Drake is a tech journalist specializing in cybersecurity and retro tech.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News