2 Tools to Perform Google Search from Terminal on Linux

Everyone knows how to google from a web browser, but an ambitious computer geek loves to shine in his or her terminal. Passion and dedication for computer systems exceed everything, the sky is the limit. Don't you believe me? Believes that you are on your server without graphic environment and you need to verify an error message which appears. You don't have a computer client to search on the web-browser and to "ssh your server", so you need absolutely a solution to do research directly on the server. You need a magic solution and we will give you a way to follow.

In this article, I will teach you how to use google from the terminal. But first, let me tell what do we need in order to do this geeky experiment. We need the following:

  • An Ubuntu Linux
  • A Terminal
  • An Internet Connection
  • w3m or googler

1.w3m

What is w3m? w3m is a World Wide Web (WWW) text based client which can be used to display html documents as well as a pager. I am sure that everyone who is reading this article and has knowledge about more or less tools understands what I am talking about when I say you can use the w3m tool 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.

a. Install w3m

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

On Debian, Mint, Ubuntu you can do

# apt-get install w3m w3m-img

b. Google From Terminal

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

Do you guys use gmail? The cool thing is that you can access your gmail account directly from the terminal via the w3m tool.

how to google from terminal

Hey, you binary geeks, I think it is time to read some articles from our site linoxide, but this time from the terminal. We don't need a web browser, we are linux geeks, we will use a good tool to reach our site from the terminal!

# w3m www.linoxide.com

Awesome! We can read linux article directly from the terminal.To be honest with you guys I am feeling very happy right now. Yesterday, while reading something about system administration my google chrome browser crashed and everything went white, I couldn't browse. But where there is a terminal, there is always a way. I wish a knew this tool before!

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

Ok geeks, one last thing! You can use the w3m tool with the -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.

a. 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

b. Search from terminal

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

There is a part of some 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.

 Conclusion

Now we are able to navigate over our terminal. This can help you if your browser doesn't work well and you need to continue your work.

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.