You can’t remember everything. When it comes to configuring and managing a Linux server there is an awful lot to remember. We’ve probably all had the experience of being in the middle of something at the command line and then forgetting the exact sequence of flags or commands to achieve what we want. Sometimes a man page’s wall of text of can be slower to comprehend than finding your answer in someone else’s guide. When this happens, only a quick trip to a search engine window can help.
No Service Tech Woes
Sometimes you may not want to move away from the command line and break your flow. Or, as anyone who has ever done co-location hosting will probably know, you can sometimes find yourself in the bowels of a data center with no mobile phone signal and the only internet connection you have is via the command line interface of the server you are working on. It’s called being between a rock and a hard place!
If you ever find yourself in this situation, wishing you could do that search on your server – there is a solution in Googler! Googler is a command line tool that will take a query from you and will then return the textual result from a search via Google. This provides you with both links to websites and the overviews of the page it links to. You can then quickly use a text mode browser to view the page to access your answer.
To find the answers to all of your Linux questions, make sure that you visit this page. Your command line life will get easier, we promise.
What is Googler?
Googler itself is a Python powered tool and is available on GitHub. The easiest way to fetch it for use is to use ‘Git’. Let’s start by installing ‘Git’. You will need ‘Make’ to perform the install so we’ll also include instruction to install ‘Make’. To get the most out of Googler you’ll need to have a web browser installed. If you don’t have one, I recommend ‘Lynx’. For Debian/Ubuntu users, ‘Git’ can be installed with:
sudo apt-get update
sudo apt-get install git make lynx
For CentOS/RedHat users it can be installed with:
sudo yum install git make lynx
With Git installed, you can now clone the repository for Googler from GitHub:
Now change to the freshly created Googler directory and install it:
sudo make install
Googler is now installed and ready for use. There are some BASH completion options available that come with it that can be installed. To install this on Debian, Ubuntu, CentOS and Red Hat use the following command:
sudo cp auto-completion/bash/googler-completion.bash /etc/bash_completion.d/
The next step is to ensure that Lynx is now set as the default web browser. To do this we’ll set an environment variable in /etc/profile.d
sudo nano /etc/profile.d/browser.sh
Next paste in the following line:
Now save and exit the file. Changes will only take place after your next login. So for this session, you can paste the export line in at the command line to set the variable.
Once finished, Googler is now ready to go, and can load web pages from the searches into your web browser for reading. Using Googler is as simple as:
This will bring up a screen with results for the Google search 100TB. There will be a small prompt at the bottom of the screen, and by default Googler will return ten results. You can enter the number before a search result at the prompt and the page it relates to will be opened in Lynx for you to browse and read. Googler has a number of extra flags you can use that can be accessed by using:
Alternately, when in Googler you can type a question mark (?) at the prompt in order to get a list of command help on the screen. Anything you type that isn’t a command will become a new search. When you want to quit, you can simply hit the ‘q’ key.
There you have it – the power of Google and all the information you may need at your fingertips while at the command line. You never know just when you might need it.