173

How can I browse the Internet from the command line in Ubuntu?

0

14 Answers 14

146

There are actually a bunch of text-mode web-browsers, these are my top three :)

  • ELinks (install):

    elinks screenshot

    • Keyboard Shortcuts

      • Open new tab - t
      • Goto URL - g
      • Go back - Left
      • Go forward - u
      • Exit - q
      • Toggle images - *
      • Toggle link numbering - .
      • Toggle document colours - %
      • Next tab - >
      • Previous tab - <
      • Close tab - c
      • Open in new tab in background - T
    • Automatic URL rewrites

      • d - dictionary search
      • dmoz - dmoz search
      • g - google search
      • wiki - wikipedia search

    (source)




Wikipedia has a List of more text-based web-browsers, not all of which are available in Ubuntu.

2
  • 1
    Its a very old post and my question is also odd but can you tell while browsing internet using w3m how to open a "linked" new tab website.. Just like Open link in new tab feature available in chrome. If this cant be done in w3m can you suggest any other text-mode web-browsers
    – Eka
    Apr 10, 2015 at 20:25
  • 1
    Wow, thanx for mentioning elinks' inbuilt search rewrites ("smart prefixes").. somehow missed them although I've been using elinks (with joy!) for years! here's a conf line to invoke it nicely from inside tmux, the 21st century terminal multiplexer: bind-key g command-prompt -p "google:" "split-window -c '#{pane_current_path}' -p 90 'elinks -no-home -no-connect \"g %%\"'"
    – eMPee584
    Jul 15, 2015 at 11:22
81

To my surprise it exists; I installed it and it works!

 sudo apt-get install w3m w3m-img
  • to open a webpage simply type in a terminal window: w3m <url_of_the_webpage>
  • to open a new page: type Shift-U
  • to go back one page: Shift-B
  • open a new tab: Shift-T

W3M can handle Gmail(!)

If you use for example XTerm (not Gnome Terminal), W3M is even capable of showing images!

For more information see “How to Browse From the Linux Terminal With W3M”.

8
  • Wow! This is amazing! Though lynx is better but w3m is the best!!
    – opu 웃
    May 3, 2014 at 13:38
  • @Scotia what do we need Firefox for :) May 3, 2014 at 13:40
  • 1
    @ Jacob Vlijm, Yes! There is no need of firefox now! ;)
    – opu 웃
    May 3, 2014 at 13:44
  • 2
    OMG! This thing made my day! Managed to login to some website and download some software I needed on a remote server! Even has a nice progress bar! EPIC!
    – paul-g
    Feb 11, 2016 at 18:52
  • This comes pre-installed with Ubuntu Server 12.04 LTS Jun 27, 2017 at 23:33
23

links2 -g is a strange terminal-embedded graphical-mode browser. It's fast but hates modernity.

If you like to search from the command line, try surfraw .

   Surfraw  provides  a fast unix command line interface to a variety of
   popular WWW search engines and other artifacts of power.  It reclaims
   google,  altavista, dejanews, freshmeat, research index, slashdot and
   many others from the false‐prophet,  pox‐infested  heathen  lands  of
   html‐forms,  placing  these  wonders  where they belong, deep in unix
   heartland, as god loving extensions to the shell.

Trivia note : Surfraw was originally written by Julian Assange. (Acronym/backronym for 'SURFRAW' is Shell Users' Revolutionary Front Rage Against the World Wide Web.)

Here's some example usage. To search Google for "nm-applet memory leak" :
sr google nm-applet memory leak

To search for an RFC dealing with S/MIME:
sr rfc s/mime

Translate a word:
sr translate logiciel

Find torrents:
sr piratebay natty narwhal

More advanced, from surfraw.alioth.debian.org :

     $ surfraw google -results=100 RMS, GNU, which is sinner, which is sin?
     $ sr wikipedia surfraw
     $ sr austlii -method=phrase dog like
     $ /usr/lib/surfraw/rhyme -method=perfect Julian

You can set it up with some defaults in .config/surfraw/conf :

SURFRAW_graphical_browser="/usr/bin/links2 -g"
SURFRAW_text_browser="/usr/bin/elinks"
SURFRAW_graphical=yes
0
15

If you meant a CLI based Internet browser, use w3m:

w3m 'http://example.com/'
6
  • 1
    There's also links, which I personally like better than w3m.
    – Cedric
    Mar 8, 2011 at 17:13
  • 1
    links or lynx? I prefer curl -vvv http://example.com/ 2>&1 | less, but that is not really a browser.
    – Lekensteyn
    Mar 8, 2011 at 17:24
  • Thanks I was looking for the www command line browser. Looks like w3m is it, or something very close!
    – jerome
    Jan 6, 2013 at 3:09
  • @Lekensteyn Is there a way to make less skip all the HTML tags? A lot of websites today have things like ad banners and tags that link to Google Analytics or something and it makes it really hard to read the content.
    – Arc676
    Jul 31, 2015 at 16:53
  • @Arc676 You could try the html2text program to interpret tags and convert them to text (installable from the repos, manual page.
    – Lekensteyn
    Jul 31, 2015 at 17:46
15

My personal favorite of the text-based browsers is links2. You can install it with

sudo apt-get install links2

And then load a webpage with

links2 www.google.com

Other alternatives that have not been mentioned are:

  • elinks : "an advanced and well-established feature-rich text mode web (HTTP/FTP/..) browser. ELinks can render both frames and tables, is highly customizable and can be extended via Lua or Guile scripts. It is quite portable and runs on a variety of platforms"

  • retawk : "an interactive, multi-threaded network client (web browser) for text terminals on computers with Unix-like operating systems. It is written in C, fast, small, nicely configurable, and comfortable; e.g. the low-level network communications are performed in a non-blocking way, and you can keep open as many "virtual windows" as you want and work simultaneously in two of them in a split-screen mode"

  • netrtik

11

Another very good command line browser is lynx.

The most basic usage would be:

lynx http://askubuntu.com

It will most likely ask if you want to allow cookies.

To navigate the page use the arrow keys. Here is a short description of the most important ones.

  • Left - move back in history
  • Right - follow a link
  • Up - move to previous focusable item
  • Down - move to next focusable item
  • Enter - enter link / trigger action
  • Backspace - history page
  • Space - move page down by a page
  • b - move page up by a page
  • Shift + q - Quit

That is the most basic key navigation commands.

10

Browsh might be a solution. From the site:

Browsh is a fully-modern text-based browser. It renders anything that a modern browser can; HTML5, CSS3, JS, video and even WebGL. Its main purpose is to be run on a remote server and accessed via SSH/Mosh or the in-browser HTML service in order to significantly reduce bandwidth and thus both increase browsing speeds and decrease bandwidth costs.

It uses headless Firefox in the background to run the interactive stuff. It's frequently updated.

2
  • 3
    Would you please edit your answer to include the main purpose of Browsh, how to download/install and perhaps a how to nav around within it etc. Thanks Jul 17, 2018 at 18:13
  • @xtrchessreal ssh into brow.sh( ie open terminal alt+ctr+t, then type ssh brow.sh)
    – suhailvs
    Dec 15, 2018 at 1:35
8

You want a text browser or a command line method? This is command line, using telnet e.g.

telnet askubuntu.com 80

GET /

It doesn't support SSL, graphics, HTML5 etc and you might have to guess the index page if the server doesn't have a default file. But it is better than nothing and a very quick testing tool.

1
  • 15
    This is the worst web browser ever :D Feb 27, 2014 at 17:29
6

Yes, you can use lynx.

From man lynx:

Lynx is a fully-featured World Wide Web (WWW) client for users running cursor-addressable, character-cell display devices (e.g., vt100 terminals, vt100 emulators running on Windows 95/NT or Macintoshes, or any other "curses-oriented" display). It will display hypertext markup language (HTML) documents containing links to files residing on the local system, as well as files residing on remote systems running Gopher, HTTP, FTP, WAIS, and NNTP servers. Current versions of Lynx run on Unix, VMS, Windows 95/NT, 386DOS and OS/2 EMX.

You can install it by executing the following command:

sudo apt-get install lynx-cur
3
  • 1
    I have installed lynx. But how can I open it? It is not in dash!
    – opu 웃
    May 3, 2014 at 13:27
  • 2
    Since you're asking for a terminal browser, you should just execute lynx in your terminal. May 3, 2014 at 13:27
  • 1
    oh yea!! Now I got it!!
    – opu 웃
    May 3, 2014 at 13:29
4

You can use W3M for this purpose.
Also there is lynx.

They can handle basic features, and are ok if you want to set up your router via your home workstation by ssh, for example.
I would prefer using a local instance of a browser forwarding connection with ssh

3

Another program that might work for you is lynx. It is a terminal based web browser.

3

If you'd like to avoid extra installations, you can hand-craft http requests. This is an http minimal request:

printf "GET /\r\nHost: askubuntu.com\r\n\r\n" | netcat askubuntu.com 80

This is an https request:

printf "GET /\r\nHost: askubuntu.com\r\n\r\n" | socat - OPENSSL:askubuntu.com 443
2

You can use the browser lynx. It is available in the Ubuntu repositories:

sudo apt-get install lynx

Here is further information: http://en.wikipedia.org/wiki/Lynx_(web_browser)

0

A chromium based browser has been released called carbonyl

https://github.com/fathyb/carbonyl

Docker

 docker run --rm -ti fathyb/carbonyl https://youtube.com

npm

npm install --global carbonyl
carbonyl https://github.com

enter image description here

You must log in to answer this question.