1. Overview

In this tutorial, we’ll compare text-mode web browsers in Linux, while going over a brief overview of each one.

We’ll start by looking at one of the most basic examples, Lynx, a pure text-only web browser. After that, we’ll discuss  Links, which provides inline-image support, and ELinks, which supports basic JavaScript. Finally, we’ll end by looking at W3m which provides Emacs compatibility and inline-image support.

2. Introduction to Text-Mode Web Browsers

In this section, we’ll compare different text-mode web browsers and then go over some important installation and configuration information.

2.1. Comparing Features

Different text-mode web browsers come with various features. Some of these features may negatively affect performance or security. This is important to consider when determining which browser to use:

Browser

Repository

Inline Images

JavaScript

Browser Tabs

History

Bookmarks

Lynx

https://lynx.invisible-island.net/current/

No

No

No

Current Session Only

Yes

Links

http://links.twibright.com/download/

Yes

No

No

Yes

Yes

ELinks

https://github.com/rkd77/elinks

No

Basic

Yes

Yes

Yes

W3m

https://github.com/tats/w3m

Yes

No

Yes

Yes

Yes

If a browser supports inline image display, we can view images within the webpage. Otherwise, image links must be viewed using an external program.

2.2. Installing From Source

Since many package managers don’t have an up-to-date version of the browsers covered, it’s usually best to install from source. Generally, most packages use autotools for installation.

The first step is configuring our project. Let’s begin by listing the various configuration options:

$ ./configure --help
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
...

In this example, we get a list of all available options by running ./configure –help. After determining what options we need, we can install our package:

$ ./configure --prefix="$HOME/.local/"
$ make
$ make install

First, we execute the configure script with the options we want to use. Here, we only use the –prefix option which sets the install location for our package. The XDG Base Directory Specification recommends that user-specific packages be installed in the $HOME/.local directory.

If we don’t specify an install location, the package typically installs globally in the /usr/local directory.

Finally, we can just run the make and make install commands to compile and install our package.

2.3. Displaying Graphics in TTY

Some text-mode browsers support graphics in the TTY through the use of the framebuffer. However, before we are able to write to the framebuffer, we must ensure our user has the correct read and write privileges:

$ usermod -a -G video "$USER"

Here we use the usermod command to add the current user to the video group, the GID that has permissions over /dev/fb* (Frame Buffer Device). This gives the user permission to read and write to all of the framebuffer device files. After running this, we should be able to use supported browsers to view images within the TTY.

2.4. Setting the Browser Home Page

To set the default home page for our text-mode browsers, we can edit our $HOME/.bashrc file**:

$ export WWW_HOME="https://www.baeldung.com"

To declare the environment variable $WWW_HOME, we can use the export command. This sets the home page for all browsers mentioned and typically takes precedence over values set in their respective configuration file.

3. Lynx

Lynx is one of the oldest text-mode web browsers still being actively maintained. It’s simple and fast, but lacking in all but the most basic features.

3.1. Installation

We can begin by downloading and extracting the latest version. After this, we can proceed with the installation of Lynx:

$ ./configure --with-ssl --prefix="$HOME/.local/"
$ make
$ make install

The default configuration should be fine. Importantly, we just need to run ./configure with the –with-ssl option if we want to use HTTPS.

3.2. Getting Started

To start the Lynx browser, we can run the lynx command in our terminal:

$ lynx

Running lynx by itself will open the browser to the home page if set. If we run lynx with a URL as an argument, it opens up into that instead.

Since Lynx is best used with the keyboard, it’s important we know some basic keybindings:

Key

Action

Enter, Left Mouse Button

Go to the link under the cursor

/, n, N

Search within the document, next occurrence, previous occurrence

g, G

Go to URL, edit the current URL

o, Middle Mouse Button

Open option menu, open navigation menu

Up Arrow, Down Arrow

Next link, previous link

Left Arrow, Right Arrow

Back button, forward button

k, K

List keybindings

q, Q

Quit browser, quit browser without prompt

Backspace

Show current session history

By default, the lynx command won’t allow mouse input, but it can be enabled:

$ lynx -use_mouse -scrollbar

Here we use the -use_mouse option to enable mouse input with lynx. We also enable a mouse controllable scrollbar using -scrollbar.

3.3. Configuring

The default config file for Lynx is /etc/lynx.cfg. Listed below are some basic config settings we may want to adjust:

Setting

Purpose

MAKE_LINKS_FOR_ALL_IMAGES

If set to TRUE, will not use the ALT value for images and instead provide a web link. We should set this to TRUE if we want to be able to view images in an external program.

XLOADIMAGE_COMMAND

Defines the external program to open image links with. If we want to open our images using xdg-open, we can include this line, but keep it blank.

SET_COOKIES

We can set this to prevent being asked to accept or deny cookies every time we visit a website. Set to FALSE to automatically deny cookies, and TRUE to automatically accept them.

There are also some settings saved to the ~/.lynxrc file. While running Lynx we can modify these settings using the options menu.

Settings changed through the options menu are temporary, but some of them are able to be made persistent by selecting Save options to diskThese options will overwrite all of the previous values in our ~/.lynxrc file.

Links is an early text-mode browser with support for many features including displaying graphics in terminal emulators and the TTY.

4.1. Installation

The INSTALL file includes instructions on installation including a list of libraries that are either required or optional. To begin, we should install any libraries we need like graphics drivers, and run the ldconfig command.

After getting the libraries we need, we can begin the installation process:

$ ./configure --enable-graphics --prefix="$HOME/.local/"
...
Configuration results:
...
$ make
$ make install

Overall, most settings used by configure shouldn’t have to be modified, with the exception of –enable-graphics for graphical mode support.

At the end of the output will be a table listing our configured settings. Once we verify these settings are correct, we can make and install our program.

4.2. Getting Started

To start the browser, we can run the links command:

$ links

Running links by itself opens up the browser in text mode. To start links with graphics enabled, we can use the -g flag:

$ links -g

Using the -g flag with links will open up the browser using the first graphics library found.

To specify which driver we want links to use, we should use the -driver option:

$ links -driver 'fb'

Here we run links in graphics mode using -driver to ensure the use of the fb (framebuffer) driver.

4.3. Configuration

Configuring links works from the browser menu. To open it, we can press the key. While there, we can navigate to the View or Setup tab.

Saved options are located  either in *.*html.cfg for HTML options or in .links.cfg for everything else. Both of these files are typically located in the ~/.links directory.

ELinks (Extended Links) is a fork of the Links web browser with additional features, including basic JavaScript support and browser scripting. Since the main codebase is no longer actively maintained this article focuses on the actively maintained fork formerly called felinks.

5.1. Installing

Instructions on installing and using JavaScript can be found in ecmascript.txt. Supported JavaScript engines include mujs, quickjs, and spidermonkey.

After downloading the source code and any necessary libraries, we can begin installing:

$ ./autogen.sh
$ ./configure --prefix="$HOME/.local" --with-quickjs
Feature summary:
...
ECMAScript (JavaScript) ......... yes
...
$ make
$ make install

First, we run autogen.sh to create the configure script. Then, we run the configure script using the –with-quickjs flag to enable JavaScript.

After that, we just compile and install our program with make.

5.2. Getting Started

To get started, we can simply run the elinks command in our terminal:

$ elinks

Most keybindings are the same between ELinks and the previous browsers we discussed, but there are some important exceptions:

Key

Action

t, c

Open Tab, Close Tab

<, >

Previous Tab, Next Tab

e, o

Open Tab Menu, Open Option Menu

h

Open History Manager

It’s also possible to interact with a remote instance of elinks:

$ elinks -remote "www.baeldung.com" "www.baeldung.com/linux"

Here we use -remote to open a series of URLs in new tabs on an already running elinks session.

5.3. Configuring

The settings of ELinks are in the ~/.elinks/elinks.conf configuration file. This file can be edited either directly or through the browser’s options menu.

Let’s look at some settings we may want to adjust:

Setting

Purpose

ui.sessions.homepage

Set default home page. If Overrides the environment variable $WWW_HOME.

connection.ssl.https_by_default

Makes HTTPS the default protocol used when one is not specified.

ecmascript.enable

Enables JavaScript support.

To initialize the elinks.conf file, we can set Configuration system -> Saving style to 1 in the options menu and save. This adds any settings not already inside elinks.conf to the end of the file, and adds a comment summarizing what each setting does.

6. W3m

W3m is a pager that doubles as a text-mode browser. Features include Emacs support and the ability to show inline images in a terminal emulator or TTY.

6.1. Getting Started

We can open up the browser using w3m by either passing it a URL or using the -v flag:

$ w3m -v

Using -v with w3m opens up the browser to a basic welcome screen.

Navigation in W3m uses the arrow keys or hjkl to move the cursor. To go to a link, we can hover over it and press . Here are a few other important keybindings:

Key

Action

o, m

Open Options Menu, Open Navigation Menu

,

Next link, previous link

H

Show Current Keybindings

U

Go to URL

I

Open Image in External Program

Ctrl-H

Show History Page

In addition to being able to browse webpages, w3m can also be used as a pager:

$ w3m <<< "$(w3m -show-option)" 
...
    -o clear_buffer=              Free memory of undisplayed buffers
    -o decode_cte=                Decode Content-Transfer-Encoding when saving
...
≪ ↑ ↓ <*stream*>

In this example, we use w3m to view the output of w3m -show-option.

Since w3m is a pager we’re able to view text just as we would with a command like less. We can do this by passing a file to w3m or by passing a stream of data to be treated as a file, using a here string.

6.2. Configuring

Config files are located inside ~/.w3m/. However, in most situations, it isn’t necessary to edit the configuration files directly. Instead, it’s preferred to use the options menu.

If we want to use Lynx-like keybindings, we can copy the provided keymap.lynx file to our ~/.w3m/ directory:

$ mkdir -p ~/.w3m
$ cp /usr/share/doc/w3m/keymap.lynx ~/.w3m/keymap

Likewise, if we want to revert back to the default keybinding, we can simply copy back the keymap.default file.

6.3. Image Display

To start w3m with inline image display enabled, we can use the -o flag:

$ w3m -o display_image=TRUE "https://baeldung.com/linux/"

Here, we run w3m with the -o flag to assign a value to a configuration setting, in this case, display_image.

The default image display method uses w3mimgdisplay, but it also supports other methods.

6.4. Using W3m in Emacs

A unique feature of W3m is its ability to run inside Emacs. To do this, we’ll have to install emacs-w3mIt’s important that the install location’s set to the ../emacs/site-lisp directory. After that, we’ll just need to edit our initialization file to load W3m:

(require 'w3m-load)

After adding this line to our init file, we can start w3m in Emacs by pressing M-x w3m.

7. Conclusion

In this article, we compared four different text-mode web browsers and then walked through a brief overview of each one.