All Languages English

Linux Terminal Browser: Surf the Web the Old-School Way

Browse the web from your Linux terminal using w3m & Links2! Easy install guide + launch graphical browsers too. Try it now!

linux terminal browser w3m browser linux links2 linux command line browser linux command line web browser browse web terminal linux cli browser xterm w3m install w3m linux linux browser from command line

Surfing the Web from Your Linux Terminal: A Deep Dive

It might sound antiquated, but browsing the web from your Linux terminal offers surprising advantages, particularly for server management or when a lightweight browsing experience is preferred. This guide will walk you through installing and using text-based browsers like w3m and Links2, and even show you how to launch your graphical browser from the command line. Let's dive in!

First Things First: Installing w3m – The OG Text Browser

w3m is a venerable text-based browser. It's not visually stunning, but it's efficient and reliable. It's typically not pre-installed, but installation is straightforward:

  • Ubuntu/Debian: Open your terminal and type sudo apt install w3m, then press Enter. You'll need to enter your password.
  • Red Hat/Fedora/CentOS: Use sudo dnf install w3m.
  • Arch Linux/Manjaro: The command is sudo pacman -S w3m.

Remember that sudo grants administrative privileges, so it's essential for software installation.

Enhancing w3m with xterm

While w3m works in a standard terminal, its functionality is limited. xterm, a more advanced terminal emulator, unlocks extra features. It allows right-clicking within w3m for convenient access to functions like back navigation, viewing page source, bookmarking, and quitting.

Install xterm using the same commands as above, substituting w3m with xterm. For instance, on Ubuntu: sudo apt install xterm. Launch it by typing xterm in your terminal and pressing Enter.

Time to Browse: Using w3m

With w3m installed, browsing is simple. Use the command:

w3m www.wikipedia.org (or any URL)

Press Enter, and you'll see Wikipedia rendered in text. Note that image viewing requires xterm.

Navigating the Text Web with w3m

w3m navigation is surprisingly intuitive:

  • Arrow Keys: Navigate up, down, left, and right.
  • Enter/Return: Follow selected links.
  • Text Boxes: Click (or navigate to) the box, press Enter, type your input, and press Enter again.
  • Back Button: Press B.
  • New Tab: Use Shift + T.
  • Viewing Images (with xterm): Select the image and press i.
  • Searching: Press /, type your search term, and press Enter. Use n for the next result and N to go back.

Links2: A Powerful Alternative

Links2 is another excellent text-based browser, even offering a GUI mode. Installation mirrors w3m:

  • Ubuntu/Debian: sudo apt install links2
  • Red Hat/Fedora: sudo dnf install links2
  • Arch Linux: sudo pacman -S links2

Browsing with Links2

The basic command is similar to w3m:

links2 www.wikipedia.org

However, Links2 offers a graphical mode using the -g flag:

links2 -g www.wikipedia.org

This provides a window with images, a back button, and a right-click menu, bridging the gap between text and graphical browsing.

Navigating Links2

  • F9: Toggles the menu.
  • Arrow Keys/Mouse: Standard navigation.
  • Enter: Follow links.
  • s: Access the bookmark manager.

Bonus Round: Launching Your Regular Browser from the Terminal

To launch your default graphical browser from the terminal, use:

x-www-browser &

The ampersand (&) runs the browser in the background, allowing continued terminal use.

Opening Specific Browsers and Websites

For specific browsers:

google-chrome www.wikipedia.org & (Chrome) firefox www.wikipedia.org & (Firefox) chromium www.wikipedia.org & (Chromium)

Chrome's Incognito Mode

Launch Chrome in incognito mode with:

google-chrome --incognito &

Consult https://peter.sh/experiments/chromium-command-line-switches for advanced Chrome command-line options.

Final Thoughts

Mastering terminal-based web browsing might seem niche, but it's incredibly useful for system administrators and Linux enthusiasts. It's a surprisingly efficient and rewarding skill to acquire. Experiment with these tools and discover their potential!