Home DuckDuckGo How To Search DuckDuckGo From Commandline Using ddgr

How To Search DuckDuckGo From Commandline Using ddgr

By sk
Published: Updated: 5.9K views

We already know how to Google search from commandline in Linux using Googler CLI utility. Today, we are going to see how to search DuckDuckGo from commandline using ddgr in Linux. Ddgr is a commandline tool for privacy-concerned people who use DuckDuckGo as their primary search engine to search stuffs on the Web. One of the notable advantage of ddgr over googler is DuckDuckGo works over the Tor network! You can view the complete list of features below. If you are someone who mostly stay in Terminal, ddgr will save you time by avoiding the need to switch from terminal to browser to use DuckDuckGo.

Features of ddgr

Concerning about the features, we can list the following:

  • Fast and clean interface.
  • Designed to use minimum space without sacrificing readability.
  • Custom color support.
  • Instant answers.
  • Limit number of search results per page.
  • Supports DuckDuckGo Bangs.
  • Integrate with Text browsers.
  • Search using keywords.
  • Limit search by region, language, and time.
  • Supports I'm Feeling Lucky feature. i.e. open the first result in browser.
  • Do Not Track set by default.
  • Disable Safe search.
  • HTTPS proxy support.
  • Supports GNU Screen and Tmux copy-paste buffers in the absence of X11.
  • Light-weight and requires minimal dependencies.
  • Free and opensource!!

Install ddgr on Linux

ddgr requires Python 3.5 or later. Also, you need to install xsel or xclip or termux-clipboard-set to copy URLs to the clipboard on your Linux system. These packages are mostly comes pre-installed. Just in case if they are not installed already, you can install them using your distribution's package manager. For example on Debian and Ubuntu and other DEB-based systems, the prerequisites can be installed using command:

$ sudo apt-get install python3.5 xsel xclip

After installing the prerequisites,  install ddgr on Linux system using any one of the methods given below.

1. Install ddgr using package manager

ddgr is packaged for many Linux distributions and available in the official repositories. You can install it using the distribution's default package manager depending upon the distribution you use.

On Arch Linux and its variants, ddgr is available in the AUR, so you can install it using any AUR helper, for example Yay.

$ yay -S ddgr

On Debian, Ubuntu, Linux Mint:

$ sudo apt install ddgr

On CentOS:

Enable [EPEL] repository and install it like below.

$ sudo yum install epel-release
$ sudo yum install ddgr

On Fedora:

$ sudo dnf install ddgr

On openSUSE:

$ sudo zypper install ddgr

The ddgr version available in the official repositories might be outdated. If you want latest version, install from source or use standalone version like below.

2. Install latest ddgr standalone version

Git clone ddgr repository:

$ git clone https://github.com/jarun/ddgr.git

Go to the ddgr directory and run it like below.

$ cd ddgr/
$ ./ddgr

You can move the ddgr executable file to your $PATH to launch it from anywhere without having to type the full path every time.

$ sudo cp ddgr /usr/local/bin

From now on, simply type the following command to launch ddgr:

$ ddgr

3. Install ddgr from source

Make sure you have installed development tools on your Linux system. After that run the following commands one by one to install ddgr.

$ git clone https://github.com/jarun/ddgr.git
$ cd ddgr/
$ sudo make install
$ cd auto-completion/bash/
$ sudo cp ddgr-completion.bash  /etc/bash_completion.d/

4. Download and Install binary packages

ddgr is also available as binary packages for various Linux distributions. Just download the latest version from the releases page and install it using your distribution's package manager as shown below. Please note that you must have installed all required perquisites.

On Debian 10:

$ wget https://github.com/jarun/ddgr/releases/download/v1.7/ddgr_1.7-1_debian10.amd64.deb
$ sudo dpkg -i ddgr_1.7-1_debian10.amd64.deb
$ sudo apt-get install -f

On Ubuntu 18.04:

$ wget https://github.com/jarun/ddgr/releases/download/v1.7/ddgr_1.7-1_ubuntu18.04.amd64.deb
$ sudo dpkg -i ddgr_1.7-1_ubuntu18.04.amd64.deb
$ sudo apt-get install -f

On CentOS:

$ wget https://github.com/jarun/ddgr/releases/download/v1.7/ddgr-1.7-1.el7.6.centos.x86_64.rpm
$ sudo rpm -ivh ddgr-1.7-1.el7.6.centos.x86_64.rpm

Search DuckDuckGo From Commandline Using ddgr

ddgr usage is very simple!

Open the Terminal and run ddgr with your search term like below.

$ ddgr ostechnix

This command will list search results related to ostechnix keyword.

Search DuckDuckGo From Commandline Using ddgr On Linux

As you can see, ddgr returns 10 results for the search query ostechnix.

Open web pages in browser

To open any link from the search lists in the default browser, just enter the index number (prefix number) in omniprompt and hit ENTER key.

Navigate through search results

To open the next set of search results, press the letter n. To open the previous set of results, press p. You can go to the first set of results page from anywhere by simply pressing f.

Searching for new keywords

ddgr supports non-stop searching. Meaning - you don't have to re-run ddgr with your new keyword to initiate new search. Just enter the search term in the omniprompt and hit ENTER key to continue searching!

Search for new keyword using ddgr in Linux

Copy URLs to clipboard

ddgrs supports copying URLs to clipboard. To copy a specific URL from the search results to clipboard, simply press the letter c followed by the index number of the respective URL and hit ENTER. Please mind the space between 'c' and the index number.


ddgr (? for help) c 3

Here, we use c for copy the URL to clipboard and 3 is the index number. Hence the third page from the search results will be copied to clipboard. Please remember - you must have installed any one of the following utilities to use this feature.

  • xclip
  • xsel
  • termux-clipboard-set

Exit ddgr

To exit from ddgr prompt and return back to Terminal:

  • press q and hit ENTER,
  • or press ENTER twice,
  • or press Ctrl+d.

This is just enough for basic searching on DuckDuckGo. If you want to learn a few advanced search tips, read on!

Search from specific websites

To search from a certain website or blog, use -w flag like below.

$ ddgr -w ostechnix.com arch linux

The above command will return results related to arch linux in ostechnix.com.

Display complete URLs

As you may noticed in the above outputs, ddgr displays only the domain names for all search results. If you want ddgr to show you the complete URLs instead of just domain name, use -x flag.

$ ddgr -x arch linux

Display complete URLs in search results using ddgr

Search for quoted text

When you want to search for some exact texts, for example song lyrics or quotes of a famous author, just mention them inside quotes like below.

$ ddgr "You have to dream before the dream comes true"

Search for specific file type

This tip will be useful when searching for a specific type of a file to download, for example a song, video, movie or text or pdf file.

$ ddgr blockchain filetype:pdf

The above command will fetch results related to Blockchain documents in pdf format.

Limit number of searches per page

You can limit the number of search results per page you'd like to see in ddgr interface.

For instance, to display only 3 results for the given query, run:

$ ddgr -n 3 ostechnix

Display results within a specific time span

Display results updated within the last 1 month for the keyword linux in ostechnix.com site:

$ ddgr -t m 1 linux -w ostechnix.com

Fetch region-specific results

If you want ddgr to fetch search results exclusively from a certain region, use -r flag.

$ ddgr -r in-en best smartphone

This will return results from India server for best smartphone query. Visit https://duckduckgo.com/params to find your region parameter.

I'm feeling Lucky search

To perform "I'm Feeling Lucky" search, use -j flag followed by your search term as shown below.

$ ddgr -j browse web with vim keybindings

This command will directly load the first search result in your default browser.

DuckDuckGo Bangs

DuckDuckGo bangs allows you to search directly on your favorite websites and blogs, without having to visit them first. Bangs are just shortcuts that quickly take you to search results on other sites.

To perform a DuckDuckGo Bang search, run:

$ ./ddgr \!ostech linux

The above command will directly take you to ostechnix.com blog and display the results related to “linux” search term. Bangs will work at the omniprompt as well.

To learn more about Bangs, refer the following link.

Disable Safe search

Unlike Google, DuckDuckGo will filter contents from adult/porn websites by default. If you want to disable the Safe search feature, use:

$ ddgr --unsafe <search-term>

Display IP address

To display your public IP address in the Terminal using ddgr, run:

$ ddgr -n 1 --np ip

Integrate ddgr with Text browsers

We can integrate ddgr with several Text-browsers such as elinks, links, lynx and w3m or www-browser. ddgr will work out of the box with the text browsers if the BROWSER environment variable is correctly set.

For example:

$ export BROWSER=w3m

For one-time use,

$ BROWSER=w3m ddgr dns

Or, do site-specific search:

$ BROWSER=w3m ddgr -w ostechnix.com arch linux

This command will search for arch linux query in ostechnix.com. When you type the index number of any link and hit ENTER key, it will open in w3m browser by default.

To make it permanent, add the BROWSER environment variable in ~/.bashrc file.

$ echo “export BROWSER=w3m” >> ~/.bashrc

Getting help

To view the list of all supported options along with description, run:

$ ddgr --help

Or, shortly:

$ ddgr -h

You can also press the ? (question mark) to view the instant help section:

ddgr (? for help) ?

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

Related read:

Hope this helps.


Thanks for stopping by!

Help us to help you:

Have a Good day!!

1 comment

tleroy April 26, 2020 - 1:44 am

Thank you! This was relally helpfull. But I encountered issue linking lynx with ddgr. I finally wrote a script wich run lynx directly by rederecting stdin to a duckduck go querry:


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More