How to Search Google 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 a graphic environment and you need to verify an error message which appears.

In this tutorial, we learn how to search google from the Linux terminal.

Search Google from Linux Terminal Using Googler

The 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 on Ubuntu/Debian

First Download .deb file from the release page of googler for your respective Ubuntu version. Here I am downloading googler on Ubuntu 20.04.

$ sudo wget https://github.com/jarun/googler/releases/download/v4.3.2/googler_4.3.2-1_ubuntu20.04.amd64.deb

Now Install Googler using the following command:

$ sudo apt install ./googler_4.3.2-1_ubuntu20.04.amd64.deb

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

$ googler -v
4.3.2

You can search a website on google from your terminal

googler linoxide.com

You can use p and n command to fetch the 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 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

Googler Options


optional arguments:
   -h, --help            show this help message and exit
   -s N, --start N       start at the Nth result
   -n N, --count N       show N results (default 10)
   -N, --news            show results from news section
   -V, --videos          show results from videos section
   -c TLD, --tld TLD     country-specific search with top-level domain .TLD, e.g., 'in' for India
   -l LANG, --lang LANG  display in language LANG
   -g CC, --geoloc CC    country-specific geolocation search with country code CC, e.g. 'in' for India. Country codes are the same as top-level domains
   -x, --exact           disable automatic spelling correction
   --colorize [{auto,always,never}]
                         whether to colorize output; defaults to 'auto', which enables color when stdout is a tty device; using --colorize without an argument is equivalent to --colorize=always
   -C, --nocolor         equivalent to --colorize=never
   --colors COLORS       set output colors (see man page for details)
   -j, --first, --lucky  open the first result in web browser and exit
   -t dN, --time dN      time limit search [h5 (5 hrs), d5 (5 days), w5 (5 weeks), m5 (5 months), y5 (5 years)]
   --from FROM           starting date/month/year of date range; must use American date format with slashes, e.g., 2/24/2020, 2/2020, 2020; can be used in conjunction with --to, and overrides -t, --time
   --to TO               ending date/month/year of date range; see --from
   -w SITE, --site SITE  search a site using Google
   -e SITE, --exclude SITE
                         exclude site from results
   --unfilter            do not omit similar results
   -p PROXY, --proxy PROXY
                         tunnel traffic through an HTTP proxy; PROXY is of the form [http://][user:password@]proxyhost[:port]
   --notweak             disable TCP optimizations and forced TLS 1.2
   --json                output in JSON format; implies --noprompt
   --url-handler UTIL    custom script or cli utility to open results
   --show-browser-logs   do not suppress browser output (stdout and stderr)
   --np, --noprompt      search and exit, do not prompt
   -4, --ipv4            only connect over IPv4 (by default, IPv4 is preferred but IPv6 is used as a fallback)
   -6, --ipv6            only connect over IPv6
   -u, --upgrade         perform in-place self-upgrade
   --include-git         when used with --upgrade, get latest git master
   -v, --version         show program's version number and exit
   -d, --debug           enable debugging
 
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
   o [index|range|a …] open space-separated result indices, numeric ranges
                         (sitelinks unsupported in ranges), or all, in browser
                         open the current search in browser, if no arguments
   O [index|range|a …] like key 'o', but try to open in a GUI browser
   g keywords            new Google search for 'keywords' with original options
                         should be used to search omniprompt keys and indices
   c index               copy url to clipboard
   u                     toggle url expansion
   q, ^D, double Enter   exit googler
   ?                     show omniprompt help
 other inputs issue a new search with original options 

Conclusion

In this tutorial, we learned how to search google from the Linux terminal. Please let us know your search experience from the command line.

2 Comments... add one

  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.

    Reply

Leave a Comment