Surfraw, stands for Shell Users Revolutionary Front Rage Against the Web, is a fast Unix command line interface to many popular search engines such as Google, Duckduckgo, Bing, and popular websites such as Arch Wiki, Amazon, BBC, CNN, eBay, Wikipedia, w3html, YouTube and many more. Please note that Surfraw isn't a search engine. It is just a commandline interface to the search engines and many other websites. It stills needs either a graphical or text browser to function. Surfraw was originally created by Julian Assange, the founder of WikiLeaks. Now it is maintained by the surfraw-devel team.

In this brief guide, I will show you how to install and use Surfraw in Linux.

Install Surfraw On Linux

On Arch Linux and derivatives:

Surfraw is available in the default repositories. So, you can install it using pacman in Arch Linux and derivatives such as Antergos, Manjaro Linux.

$ sudo pacman -S surfraw

On Debian, Ubuntu, Linux Mint, you can install it using command:

$ sudo apt-get install surfraw surfraw-extra

Configure Surfraw

Surfraw will use your default browser (Text or GUI) to open the given queries. If your system doesn't has any standard browsers installed, Surfraw will call $BROWSER variable in its config file. If that variable too is empty, surfraw will display an error message.

To fix this, you need to create a config file and configure your default browser, and any other options.

$ mkdir ~/.config/surfraw/

Now, create a config file:

$ sudo vi ~/.config/surfraw/conf

Add the following lines.

SURFRAW_graphical_browser=/usr/bin/chromium SURFRAW_text_browser=/usr/bin/lynx SURFRAW_graphical=yes

Replace Chromium and lynx with your own if you use any other browsers. Save and close the file.

Note: If you specify SURFRAW_graphical value as No, it will search only from the text browsers. So, you need to uncomment the line SURFRAW_text_browser=/usr/bin/lynx.

Also, there is a default config file at /etc/xdg/surfraw/conf. It contains all of the configurable options.

How To Use Surfraw, the Commandline Interface To Popular Search Engines And Websites

Surfraw contains a collection of scripts called "elvi". These scripts are used to search various websites.

Run the following command to see the list of elvi:

$ surfraw -elvi

As you see in the above screenshot, Surfraw will act as command line interface for 100+ popular websites, and search engines.

For instance, to search for query "Linux" in google, run:

$ surfraw google linux

You also use its alias - "sr":

$ sr google linux

It will automatically open your default web browser and search for the query "linux".

To include "I'm feeling lucky" option, use -l as shown below.

$ surfraw google -l archlinux

The above command will directly land you on Arch Linux website.

To include multiple queries, use them as comma-separated values like below.

$ surfraw google Arch Linux, Debian, Unix

To display X number of the results, say 10, use:

$ surfraw google -results=10 Arch Linux, Debian, Unix

Surfraw is not just for searching on Google. It can act as a interface other popular search engines such as duckduckgo, bing, and yandex etc.

To search on duckduckgo, run:

$ surfraw duckduckgo Arch Linux

To search on Bing:

$ surfraw bing Arch Linux

Also, surfraw is not an interface just for search engines alone. You can use it for other popular websites like Arch Wiki, Amazon, BBC, CNN, Cisco, GitHub, yahoo, youtube, w3html and other 100+ websites.

For instance, to search a book on Amazon, just type:

$ surfraw amazon -search=books -country=en -q Think on these things

To search an article in Arch Wiki, type:

$ surfraw archwiki install fonts

Or, simply use alias:

$ sr archwiki install fonts

To search for a repository in GitHub:

$ sr github explainshell

We can also search for articles on wikipedia.

To search for a topic on wikipedia, run:

$ sr wikipedia linux

Feel bored? Search and watch your favorite videos on YouTube.

$ sr youtube somebody that I used to know

I have included only a few examples. Like I said already, you can search on 100+ websites using Sufrraw. For the complete list of supported sites and search engines, run:

$ sr -elvi

Bookmarks

Surfraw supports bookmarks. To add a bookmark, add it to /etc/xdg/surfraw/bookmarks or $HOME/.config/surfraw/bookmarks files. Each bookmark should be added in a separate line, with the bookmark and URL separated by whitespace, like below.

ostechnix https://ostechnix.com/ surfraw http://alioth.debian.org/projects/surfraw/

To invoke a bookmark, use "surfraw bookmark" or "sr bookmark", and if an elvis of that name doesn't exist, it searches for a bookmark of that name instead.

For more details, refer the man pages.

$ man surfraw

Related read:

Hope this helps.

Resource: