Surfraw – A Commandline Interface To Popular Search Engines And 100+ Websites
Surfraw 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.
Surfraw – A Commandline Interface To Popular Search Engines And Websites
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
If Surfraw is not available in your distribution’s repositories, you can install it from source.
Install from source
Download the latest version from Surfraw website. As of writing this guide, the latest version was 2.2.9.
Unpack the source using command:
gzip -dc surfraw-2.2.9.tar.gz | tar xvvf -
Then, change into the surfraw-2.2.9 directory, and type:
Finally, run this command to install it:
sudo make install
This will install surfraw into /usr/local/. For more detailed installation instructions, check this link.
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.
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.
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:
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:
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://www.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.
And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned!
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!