Browsing the Internets from the terminal

Summary:

Links2 is a text-based web browser that can be run from the terminal, but also has the ability to display graphics. In Debian the installation is simple, since the application is in the repositories. Shortcut keys and additional options are shown.

Posted: April 24th, 2010 | Keywords: , ,

When I installed a version of Linux on my desktop, I played around with the bootloader and accidentally broke it. Thankfully I had my handy hacked Zipit Z2 to let me search online. At the moment, I didn’t have a graphical browser, so I used the awesome text browser: Links2. I’ll show you how to install it, and the basic commands to get around online. (Links2 is a dual-mode browser: If I’m inside an X environment, it will display graphics, but from the console it won’t.)

I’ll probably end up getting familiar with other Linux system commands after a while, but for now I’ll only be able to provide instructions for Debian systems, and in Debian Links2 is already in the repository, so nothing special is required: sudo apt-get install links2

  • sudo You’ll need to have admin rights to install things
  • apt-get This runs the program “apt-get”, which is what most Debian installs use to access the repository of programs. You could also use aptitude if you have it installed
  • install This is the “flag” to pass to the program “apt-get”, which will tell it to go ahead and install a program.
  • links2 This is the program to install
  • While I don’t use it, the Fedora/RedHat systems installation appears to be a little more involved, judging from this post (has instructions).

    Once Links2 is installed, you can access it from the terminal using this structure: links2 [options] URL (If you don’t specify a URL, Links2 will open to a blank page. Access the menu by pressing Esc)

    The [options] you can use are as follows (this list is basically from the links2 --help readout, but explained a bit more):

    • -g This runs Links2 in graphics mode. You may be able to browse with graphics without starting X, I already had it installed so I’m not sure what it references.
    • -no-g If you are in X it will default to display graphics, but this will tell it to revert to text only.
    • -source This one has to be right before the URL (eg., links2 -source URL ). It will output the text source code of the page instead of rendering it as HTML.
    • -force-html If a page isn’t understood by Links2, it might not display as HTML, this will force it to try.
    • -dump This one also has to be right before the URL. It will render the page as HTML and dump it to the screen, so the program won’t be running.
    • -fake-user-string [string] The browser tells the website you visit what browser you are using, that way the server can give you a page ideally constructed for your browser. There is a huge list of strings at this link.

    There are actually piles and piles of different options you can change, but if you want to make something permanently changed, you should change the configuration file for Links2, which is located in the file links.cfg

    If you installed Links2 in a Debian environment, you can probably find the configuration folder using: cd $HOME/.links2

  • cd This is the command to change directories
  • $HOME This is a shortcut (it must be typed in capital letters) to the home directory of the current user, it’s really handy
  • /.links2 A dot in front of a file or folder hides it—most configuration files are hidden
  • Make sure to make a backup copy of the configuration file before you change anything! A sample one can be found here, if you want to look at it.

    Start up links2 and go somewhere like Life Hacker (notice that Links2 doesn’t require the “http://” prefix): links2 lifehacker.com

    Navigation in Links2 is with keyboard shortcuts, the most important ones being these:

  • esc This shows the menu bar for Links2 (navigate it with the arrow keys), which will also show you the rest of these commands
  • g Lets you enter a new URL
  • / Opens a search prompt, letting you look for words on the page
  • left/right arrow These are the keys to navigate browsing history: Left is “back”, right is “forward”
  • page up/down Navigates up and down one page at a time. Depending on your computer setup, the up/down arrow may do the same, and the space bar and b keys will do the same if you can’t get the other ones to work.
  • s This shows a list of bookmarks, you can bring this up and add the current page to the list
  • I have taken rather fondly to the text-only browser — I’m trying to get Facebook and the WordPress admin page to load correctly, that will be awesome!

    There is a comment, go and read it »