links Command in Linux



links is a command used in Linux to browse websites from the command line. It is a text-based web browser that you can use to view images or fancy layouts as plain text.

The links command is useful in case you are working on a server without a graphical interface or you need a quick, lightweight way to access the Internet. You can easily navigate using the keyboard shortcuts and it is a perfect fit for accessing documentation or online resources without leaving your terminal.

Table of Contents

Here is a comprehensive guide to the options available with the links command −

How to Install links Command in Linux​?

To install links on a Linux system, you usually need to use your package manager. For example, on a Debian-based system like Ubuntu, you can use −

sudo apt install links

For Red Hat-based systems like CentOS or Fedora, simply use −

sudo yum install links

For Arch Linux, use the following command to install links

sudo pacman -S links

On OpenSUSE, you can run the below-given command to install links on Linux −

sudo zypper install links

Syntax of links Command

The basic syntax to use the links command on Linux is provided below −

links [options] URL

Where,

  • links is the command used to open the text-based web browser.
  • [options] are optional flags that modify the behavior of the command.
  • URL is the web address you want to visit.

links Command Options

The following are few options that can be used with the Linux link command −

Options Description
-g Starts links in graphics mode, if supported.
-dump Dumps the formatted output of the given URL to the terminal.
-width Sets the width of the formatted output.
-source Shows the source of the given URL in the terminal.
-html-t-text Outputs the given URL as HTML text.
-force-html Forces the document to be treated as HTML.
-lookup Performs a lookup for the given URL.
-no-openmp Disables the use of OpenMP for parallel processing.
-no-connect Runs the browser without trying to connect to the URL.
-no-color Disables color output.
-anonymous Restricts access to local files and shell commands.
-memory-cache-size Specifies the size of the memory cache.
-name Sets the window name (if running in a windowed environment).
-language Sets the preferred language for the content.
-codepage Specifies the codepage to be used for character encoding.
-retries Defines the number of retries if the connection fails.
-accept-cookies Automatically accepts cookies.
-http-proxy Sets the HTTP proxy server to use.
-http-proxy Sets the HTTPS proxy server to use.
-fttp-proxy Sets the FTP proxy server to use.
-telenet-proxy Sets the Telnet proxy server to use.

To explore more options and keyboard shortcuts to surf the internet, simply open links help section using the following command −

links --help
links Command in Linux1

Examples of links Command in Linux

Let's explore a few examples of links command on Linux system −

  • Open a Website
  • Open a Website in Graphics Mode
  • Dump the Content of a URL
  • Restrict Access (Anonymous Mode)
  • Show the Source of a URL

Open a Website

To open a website using the links, simply specify the URL after the command. This opens the site in a text-based browser on the terminal.

links http://www.google.com
links Command in Linux2

Open a Website in Graphics Mode

If you want to view the website with basic graphical support, then use the -g option. Note that this mode is only available if supported by your system.

links -g http://www.google.com

Dump the Content of a URL

To print the plain text content of a website directly to the terminal, you can use the -dump option. This is useful for quickly viewing the content without interactive browsing.

links -dump http://www.google.com
links Command in Linux3

Restrict Access (Anonymous Mode)

To increase security by restricting access to local files and shell commands, you can use the -anonymous option.

links -anonymous http://www.google.com
links Command in Linux4

Show the Source of a URL

If you want to see the source code of a webpage, use the -source option.

links -source http://www.google.com
links Command in Linux5

Conclusion

The links command in Linux is an essential command for browsing websites directly from the command line. When used, it allows you to access the internet in a text-based format, making it highly useful for servers without a graphical interface.

In this tutorial, we covered the syntax, provided different options and practical examples to help you understand how to use the links command effectively. With this knowledge, you can browse the web efficiently and ensure your Linux system is equipped for text-based web access.

Advertisements