The colorful DuckDuckGo logo, with text that reads, DuckDuckGo Command Line.

How To Use DuckDuckGo From the Command Line

  • Adam Douglas

I’ve used DuckDuckGo so many times throughout the day that I can’t even recall how many times I’ve searched for something. What I do know is that I always have to use a graphical interface to conduct my searches, even though I’m in the command line majority of the time. The dream of using DuckDuckGo in the command line is a reality thanks to an application called “ddgr”, a simple, clean, and ease to use text interface.


ddgr can be installed in the majority of operating systems. Here are a few examples on how to achieve that.

Arch Linux

$ pikaur -Sy ddgr


# apt install ddgr


# dnf install ddgr


# brew install ddgr


$ snap install ddgr


The basics of using ddgr is just simply running the command followed by a keyword. The default behavior will return a list of 10 results per page, and a command prompt waiting for your instructions.

$ ddgr adamsdesk
1.  Home - Adamsdesk []
    A hub for technology users to navigate the misleading, outdated, and
    inaccurate product information online for what is honest, clear, and

2.  Adamsdesk KB []
    Home. Welcome to Adamsdesk Knowledge Base. Recent Activity.
    2022-12-12 Arch Linux AUR Helper Add new article;
    2022-12-12 Arch Linux Pacman Fix for accuracy and clarity;
    2022-12-05 Arch Linux Install AUR Helper Add Paru AUR Helper;
    2022-12-02 Logitech K400r Add new article;
    2022-12-02 Pi-hole Quick Reference Commands Add missing command example;
    2022-11-29 Framadate Install Guide Add new ...

3.  About - Adamsdesk KB []
    Topics covered on Adamsdesk Knowledgebase is to be on all areas of life that
    are not necessarily related to computing. How It Works Adamsdesk
    Knowledgebase is primarily maintained by Adam Douglas. As this knowledge
    resource grows it may open up to the public for others to contribute. How
    You Can Help

... (intentionally trucated)

ddgr (? for help)

Here is a quick overview of the application commands.

Task Command Example Description
Copy link c 1 Copy link to clipboard by index number.
Help ? Show help.
Open link index 1 Open result corresponding to index number in a web browser.
Open link o 1 3 5 Open multiple space-separated result indices in a web browser.
Open link O 1 3 5 Same as “o”, but will use a graphical user interface (GUI) web browser instead.
Page first f Go to the first page of results.
Page next n Fetch the next page of results.
Page previous p Fetch previous page of results.
Quit CTRL-D Exit ddgr.
Quit ENTER ENTER Press the enter key twice to exit ddgr.
Quit q Exit ddgr.
Search New search for “”.
Search d New search for “”.
Show full link x Toggle displaying full links, or domain name only.

Integrate with Text Browsers

ddgr works with several text-based browsers, such as elinks, links, lynx or w3m. For the text-browser integration to work the environment variable BROWSER must be set. This can be done manually as shown below.


$ export BROWSER=w3m
$ BROWSER=w3m ddgr adadamsdesk


$ set -g -x BROWSER w3m
$ BROWSER=w3m ddgr adadamsdesk

A permanent solution would be to add the environment variable to your shell configuration file (e.g. ~/.bashrc, ~/.config/fish/


$ nano ~/.bashrc
export BROWSER="w3m"


$ nano ~/.bashrc
set -g -x BROWSER w3m


The configuration of colors can be altered from the default of “oCdgxy” using an environment variable DDGR_COLORS or a command line parameter. Each character of the total six characters represents a specific element, and are listed in order as follows.

  • indices
  • titles
  • URLs (links)
  • metadata/publishing info
  • abstracts
  • prompts

ddgr offers the following colors/styles:

Letter Color/Style
a black
b red
c green
d yellow
e blue
f magenta
g cyan
h white
i bright black
j bright red
k bright green
l bright yellow
m bright blue
n bright magenta
o bright cyan
p bright white
A-H bold version of the lowercase-letter color
I-P bold version of the lowercase-letter bright color
x normal
X bold
y reverse video
Y bold reverse video

Command Examples

  • Basic Search

      $ ddgr adamsdesk
  • Search with Bangs

      $ ddgr !w ansi escape code

    Escape the character “!” (exclamation mark) to work within Bash.

      $ ddgr \!w ansi escape code
  • Feeling Lucky

    Open the first result found in a web browser with no prompt.

      $ ddgr -j ansi escape code
  • Specific Website

    Show only results from a specific website only.

      $ ddgr -w commandline
  • Specific File Type

    Show results containing a specific file type.

      $ ddgr linux filetype:pdf
  • Convert mass ddgr -n 1 –np 4 kg to lbs

    Convert kilograms to pounds without a prompt, and returning the first result only.

      $ ddgr -n 1 --np 4 kg to lbs
  • Disable Safe Search –unsafe

      $ ddgr --unsafe
  • Display Full Links

    Show the entire link instead of just the domain name.

      $ ddgr -x adamsdesk
  • Get current public IP address without prompt -n 1 –np ip

    Display your public IP address without a prompt, and returning the first result only.

      $ ddgr -n 1 --np ip
  • Search by Region -r en-ca

    Return results by region, see DuckDuckGo params help page for more details.

      $ ddgr -r en-ca
  • Quoted Text

      $ ddgr it\'s a \"beautiful world\" in spring
      $ ddgr "it's a "beautiful world" in spring"
  • Limit Results Per Page

    Display 15 results per page.

      $ ddgr -n 15

This is post 75 of 100, and is round 2 of the 100 Days To Offload challenge.

    • add homebrew install example
    • change topic
    • correct grammar
    • add related posts
    • change 100DaysToOffload message