Command line web browser: internet search from BASH terminal

By Russell Barnes. Posted

Access a browser and search the internet from the command line

Most people aren't aware that you can access a command line web browser and search the internet from the text-based shell.

At first glance, a command line web browser doesn't make much sense. One of the advantages when using a desktop interface, like Raspbian, is that a web browser – and a search engine – is just a click away.

This article first appeared in The MagPi 56 and was written by Lucy Hattersley.

Getting online from the command line web browser is a lot easier than you’d imagine. And it's incredibly useful for searching for help, right inside the command line environment. And it's especially useful when you're working on a headless version of Rasbpian (without the PIXEL desktop interface).

There are many different text-based web browsers that enable you to access Google, Bing, DuckDuckGo, and other websites without having to boot into the PIXEL desktop interface.

Set up the ELinks command line web browser

We’re going to use ELinks:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install elinks

Now you can open the web browser from the command line using:

elinks

The elinks interface is a full-screen command line web browser, so it replaces the command line. Press g to open a URL field. You can enter full URLs, such http://www.google.com or just shortened versions, such as raspberrypi.com.

Better yet, there are a few key bindings for helpful sites. Press g then enter these shortcuts:

  • d - dict.org search
  • sd - Slashdot
  • g - Google search

You can also enter Google search terms in the URL field. Press g, then enter ‘g the magpi’ to search for our website in Google.

Other keyboard shortcuts can be used to navigate the program:

  • g - Goto URL
  • Down Arrow - Next link
  • Up Arrow - Previous link
  • Return - Select link
  • Left Arrow - Back
  • u - Forward
  • q - Quit
  • . - Toggle link numbering
  • % - Toggle colours
  • t - New tab
  • T - Open link in new tab
  • > - Next tab
  • < - Previous tab
  • c - Close tab

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.