Browsing the Internet Using W3M in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

Is it possible to access β€œlinuxtldr.com” or any other website from the Linux terminal? Yes, and you will also learn how to do it in this article.

Tutorial Details

DescriptionAccessing Webpages using W3M Command-Line Utility
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisites–
Internet RequiredYes

What is the W3M in Linux?

The W3M is an open-source Linux utility that allows you to browse web pages in a text-based format from your Linux terminal.

Alternately, you can use Lynx, another tool that the Linux community also suggests, to browse the internet from the Linux terminal.

However, there are a few differences between them, as mentioned below.

  • W3M supports inline images and tables while Lynx does not.
  • Lynx has a more basic interface than W3M.
  • W3M has advanced features like mouse support and tabbed browsing.

Concluding that, let’s move on to the installation part of the W3M.

How to Install W3M on Linux

Linux distribution does not by default include this command-line utility. However, it can be easily installed from your default package manager if you have access to the internet.

Follow the following steps to install it based on your Linux distribution:

Debian, Ubuntu, or Pop!_OS

Open your Linux terminal and execute the following command to install it from your APT package manager:

$ sudo apt install w3m

Red Hat, Fedora, or AlmaLinux

On this distribution, you use the DNF package manager to install it on your system.

$ sudo dnf install w3m

Arch, Manjaro, or EndeavourOS

Arch users can use the Pacman package manager to install it on their system.

$ sudo pacman -S w3m

Once the installation process is complete, please refer to the next section for usage instructions.

Instructions for Use

As I mentioned at the beginning of this article, it’s a text-based browser that works slightly differently than a standard browser. So, make sure to note the following key mapping:

Key MappingDescription
Arrows KeysUsed to move the pointer around the desired links.
Tab KeyUsed to jump from link to link.
Enter KeyLoad the desired link once you select it or hover over it by pressing the enter key.
Shift+BGo back.
Shift+TOpen a new browser tab.
Ctrl+HDisplay your browsing history.
β€œq” Then (β€œY” = yes) or (β€œN” = no)To quit.

How to use the W3M in Linux

There are multiple ways to use this tool, like browsing the internet or translating your written HTML. We will cover most of the examples, starting with the most basic, browsing the internet.

Visiting Websites with W3M in Text Mode

The default viewing mode for W3M without any options is text-mode; all you have to do is specify the command and type your desired URL, as shown.

$ w3m linuxtldr.com

Output:

Viewing the website from the terminal in text mode

Quite amusing, right? As you can see from the above picture, graphic elements and many more will not be rendered. So, for now, you can use this tool for most of your reading, like articles and blogs.

Visiting Websites with W3M in a Monochrome Display Mode

In the previous text mode, you had to use the arrow keys or tab key to move around the links, which was sluggish. However, you can specify the β€œ-M” flag as an argument to this command to launch the W3M in monochrome display mode.

The output will still be text-based, but all text will be stylized in monochromatic color, and you can use the mouse to click on or navigate to the links.

$ w3m -M linuxtldr.com

Output:

Viewing the website from the terminal in monochrome display mode

Use W3M as a Pager

You can pipe the W3M with another command to act as a pager and give it all the capabilities that you have while browsing.

For example, I have a β€œfile.txt” file in my home directory, and I will read its contents using the cat command and pipe them to the W3M, as shown.

$ cat file.txt | w3m

Output:

Using W3M as a pager

Translate HTML Files

Like the previous example, if you have an HTML file on your system, you can translate the HTML file content using the W3M command. But as you know, it is a text-based tool, so it cannot render the graphic material of the HTML file like CSS.

$ cat index.html | w3m -T text/html

Output:

Translating HTML files into W3M

There is a lot more you can do with this tool. However, if you don’t like it as much, you can remove it from your system by following the next section.

How to Remove W3M from Linux

Simply execute one of the following commands based on your Linux distribution:

$ sudo apt remove w3m                                                                               #Debian, Ubuntu, or Pop!_OS
$ sudo dnf remove w3m                                                                               #Red Hat, Fedora, or AlmaLinux
$ sudo pacman -R w3m                                                                                #Arch, Manjaro, or EndeavourOS 

So, here comes the end of this article.

It is quite interesting, and I’ve used it for a very long time. You will not face any issues except being kept away from the visual element of the site.

However, if you have any questions or queries related to this article, then feel free to ask them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.