Tools to Perform 'Google Search' from Linux Terminal

Everyone knows how to google from a web browser, but an ambitious computer geek loves to shine in his or her terminal. Believes that you are on your server without graphic environment and you need to verify an error message which appears. In this article we will show you two tools to access google from terminal.

1.w3m

w3m is a World Wide Web (WWW) text based client which can be used to display html documents as well as a pager. Does w3m support images? Yes it does, but you can not view images in a Gnome Terminal or KDE Console, you need an Xterm terminal to display images while browsing with this amazing tool for computer geeks.

Install w3m

The following command will help us to install the World Wide Web text based client on our Linux machine.

On Debian, Mint, Ubuntu you can do

# apt-get install w3m w3m-img

After the installation is finished, run the following command to use google from the terminal. Note: Use the arrow keys to navigate through links and boxes and type enter if you want to put text in a box.

# w3m www.google.com

Another cool thing is that, you can access your Gmail account directly from the terminal via the w3m tool.

how to google from terminal

You can use w3m as browser using below command.

# w3m www.linoxide.com

As you can see from the following screenshot, we are not able to view any image.

how to google from terminal

Xterm terminal can help us to display images and view them.

how to google from terminal

You can use the w3m tool with -M option for monochrome display. For more options read the man page.

# w3m -M www.linoxide.com

how to google from terminal

2. googler

googler is a power tool to Google (Web & News) and Google Site Search from the command-line. It shows the title, URL and abstract for each result, which can be directly opened in a browser from the terminal. Results are fetched in pages (with page navigation). Supports sequential searches in a single googler instance.

googler is developed using Python and can be found on its developer’s GitHub repository which isn't affiliated to Google in any way. It was initially written to cater to headless servers without X. You can integrate it with a text-based browser. However, it has grown into a very handy and flexible utility that delivers much more.

Install googler

Wee need to add the repo before installing it.

# add-apt-repository ppa:twodopeshaggy/jarun
# apt-get update
# apt-get install googler

Now that it's installed, you can verify the version

# googler -v
3.1

You can search a website on google from your terminal

googler linoxide.com

You can use p and n command to fetch previous or next page. If you open your browser and go to google to view the result, you will have exactly the same thing.

You can do a particular research on a website. You will indicate words. It is also possible to define the limit of the result to display.

# googler -n 5 -w linoxide.com \"Advanced Linux\"

it is possible to filter the result only for the last days or months.

# googler -w linoxide.com -t d5
press w

options available with googler:

optional arguments:
  -s N, --start N start at the Nth result
 -n N, --count N show N results (default 10)
  -t dN, --time dN time limit search [h5 (5 hrs), d5 (5 days), w5 (5
 weeks), m5 (5 months), y5 (5 years)]
 -w SITE, --site SITE search a site using Google
  -v, --version show program's version number and exit
 
omniprompt keys:
 n, p fetch the next or previous set of search results
 index open the result corresponding to index in browser
 f jump to the first page
 g keywords new Google search for 'keywords' with original options
 should be used to search omniprompt keys and indices
 q, ^D, double Enter exit googler
  * other inputs issue a new search with original options

You can visit the github repository to have the latest release and if you need more information about googler command.

 

Oltjano Terpollari 2:00 pm

About Oltjano Terpollari

Oltjano Terpollari is a very passionate computer geek studying python, linux, netcat power tools and living a binary life. He goes by the nickname Ambition and is very happy living a science life. He also loves technical blogging and sharing his knowledge with others.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.

2 Comments

  1. Thanks - didn't know about w3m; had always used a command with 'wget' to view a page from command line (though this is usually when I'm extracting info for use in script; so wget suits that purpose...)

    Incidently - I didn't even need to install it in either SuSE or DEBIAN; both had w3m installed by default.