Surfraw, find everything you need from the Ubuntu terminal

surfraw evil

In the next article we are going to take a look at Surfraw. This is one fast Unix command line interface. It does its work on many popular search engines like Google, Duckduckgo, Bing, and popular websites like Amazon, CNN, eBay, Wikipedia, w3html, youtube, and many more. Keep in mind that Surfraw is not a search engine. It is only a command line interface for search engines and websites. This metasearch engine needs a graphic or text browser to work.

Surfraw (Revolutionary Front of Shell Users Against the Web) is a metasearch engine It is used from the command line and the results of which can be viewed both in a graphical browser and in a text browser or from the console. Surfraw was originally created by Julian Assange, but today it is maintained by the surfraw-devel team.

Install Surfraw on Debian, Ubuntu or Linux Mint

To install this program we will only have to open a terminal (Ctrl + Alt + T) and write in it:

sudo apt-get install surfraw surfraw-extra

If you cannot find this interface available in the repositories of your distribution, you can install it using compiling the source code that you can download from their website. You can consult more about the platforms on which it can be installed in the project website.

Configure Surfraw

By By default, the default browser (Text or GUI) of your system will be used to open the queries made. If your system does not have a standard browser installed, it will try to call the $ BROWSER variable in its configuration file. If that variable is also empty, the application will display an error message.

To correct this, you will need to create a configuration file and configure your default browser and any other options.

mkdir ~/.config/surfraw/

Now, we will create a configuration file:

sudo vi ~/.config/surfraw/conf

Inside the files we are going to add the following following lines.

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

Replaces Chromium and lynx if you use other browsers. Save and close the file.

Note: If you specify SURFRAW_graphical as No, it will only search from text browsers.

In addition, there is a default configuration file in / etc / xdg / surfraw / conf. This contains all the configurable options.

How to use

surfraw elvi continued

Some possible searches with surfraw

In order to use this interface, we will have to our disposition a collection of scripts called «elvi». These scripts are used to search many websites. As seen in the screenshot above, Surfraw will act as command line interfaces for a lot of popular websites and search engines.

For example, to search for the query «ubunlog» in google, we will execute in the terminal:

surfraw google ubunlog

We will also be able to shorten the command using its alias "sr":

sr google ubunlog

Both commands will automatically open your default web browser and show us the results of the query «ubunlog».

To include the option "I'm going to be lucky", we just have to use -l as shown below

surfraw google -l ubunlog

The above command will land you directly on the website Ubunlog.

For include several terms to consult, we can use them separating them by commas, as shown below:

surfraw google Ubuntu, Debian, Unix

If we want to reduce the number of results, for example to show the number X of the results, say 15, we will write in the terminal:

surfraw google -results=10 Ubuntu, Debian, Unix

This interface is not just for searching Google. It can act as an interface to other popular search engines like duckduckgo, bing, and yandex, etc.

To search duckduckgo, run:

surfraw duckduckgo Arch Linux

To search Bing:

surfraw bing Arch Linux

Search on websites

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

For example, to search for a book on Amazon, just type:

surfraw amazon -search=books -country=en -q Android Phones For Dummies

To search for a repository on GitHub:

sr github explainshell

To search for a topic on wikipedia, run:

sr wikipedia Ubuntu

You can also search and watch your favorite videos on YouTube.

sr youtube zztop

Available Websites

The above are just a few examples. As I have already said, we will be able to search a good number of websites. To get the full list of supported sites and search engines, we'll run:

sr -elvi

surf raw man

We can also add bookmarks for more comfortable searches. Who wants to know more about these, can consult the help that man offers.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Fortu said

    always interesting