how to access website from linux terminal

3 Best Ways to Access a Website in a Linux Terminal

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

Sometimes, you don’t have other options. You must access a website from the Linux terminal. I know I did this a few times when I worked as a sysadmin, and I’m going to share a few tips with you in this article.

Overall, Lynx is one of the best options to access a website in a Linux terminal. It’s easy to install and works on most distributions. It allows viewing the website content in text format, following links and scrolling through the page quickly.

But I have a few other options for you, so make sure you’re reading this article until the end, as maybe some of the alternatives are better suited for your needs.

If you need help with Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your system. Click here to get it for free!

Option 1: Lynx

Lynx is a terminal-based web browser, available on all distributions. That’s the first one I learned to use, and it never disappointed me since then, so I would recommend it as your first option too.

Installation

Lynx is generally not installed by default (weirdly, most people don’t browse the web from a terminal), but you can easily install it with your package manager.

For example, on Debian or Ubuntu, Lynx can be installed with APT:
sudo apt install lynx

Any additional requirements will be added automatically, but in theory, you don’t need much. As you can see on my screenshot (Ubuntu Server), I only need to download 2 MB to install it.

If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

Usage

Once installed, Lynx can be used from the command line. It works the same way whatever screen you use (console on a server edition, SSH, terminal on a GUI distribution, etc.).

The main command syntax is simply:
lynx <url>
So, for example:
lynx raspberrytips.com

The website shows up in this format:

Obviously, websites are not optimized for this browser, but you can still find what you are looking for. Use the up/down arrows to scroll through the content.

Colors will help to understand the structure of the page.
On my screenshots, links are colored in green, you can select them and press Enter or the right arrow to follow them. Bolded text is in red, etc.

You can press H at anytime to see the help, and then click on “Key-stroke commands” for a full list of shortcuts. Here are a few useful ones:

  • Left arrow: Go to previous visited URL in the history.
  • + or Space: Scroll down to next page
  • – or b: Scroll up to previous page
  • CTRL+A: Go to first page
  • CTRL+E: Go to last page
  • q: Close Lynx

I’m clearly not using Lynx every day, but I had to use it a few times in my career and I can confirm it does its job perfectly. I would recommend installing it, and trying if it does what you need on your server. But if you want to see other options, keep reading for alternatives.

Option 2: W3m

W3m is very similar to Lynx with its core features. But it provides a more feature-rich interface with support for mouse interaction, inline image display, and tabbed browsing.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

Installation

W3m is also available in the default repository for most distributions, so you can use your package manager to install it.

For example, on Debian or Ubuntu-based systems, just use:
sudo apt install w3m

Usage

Once installed, W3m has a similar syntax to Lynx. You can open a web page with:
w3m <url>

So, for example:
w3m raspberrytips.com

The result is slightly different, but pretty much look the page we got with Lynx:

You can see in this example that links are colored in blue, bullet lists are working, so it’s readable, even if you don’t get the normal design with subheadings highlighted, images, etc.

From thee, you’ll use many shortcuts to use the more advanced features included with W3m.
Here are a few examples:

  • SHIFT + H: Open the help with all the shortcuts
  • SHIFT + B: Exit the help
  • / or ? : Search (forward or backward). Use “n” to go to the next occurrence after that.
  • SHIFT + T: Open a new tab (with the same url)
  • SHIFT + {}: Switch between tabs
  • CTRL + Q: Close the current tab
  • SHIFT + U: Edit current URL

You can find the documentation here, with more examples listed.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

If you enjoy learning about Raspberry Pi, you’ll feel right at home in the RaspberryTips Community. It’s a friendly group of makers helping each other grow. Join us today for $1 and see what it’s like inside.

Option 3: Download the web page

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

If you can’t install any new package on the system, or prefer to download the HTML code before parsing it in a script or opening it with any other text editor, here are two other options for you.

Wget

Wget is a command-line utility that allows you to download files from the Internet. It supports most web protocols (HTTP, HTTPS, FTP, …) store the target URL in a local file, on your computer or server.

Wget is often pre-installed on most distributions. It’s commonly used to download sources code from GitHub or software editors, but you can also use it to download HTML pages.

The basic syntax is:
wget <url>
For example:
wget https://raspberrytips.com

In this example, it created a file name “index.html” in the current directory. But you can specify the destination file with this option:
wget <url> -O <file>
For example:
wget https://raspberrytips.com -O /home/pat/Downloads/rpitips-home.html

From there, you can use Nano to read the HTML file (with all its tags), or send it to your computer and open it with a most user-friendly editor or web browser.

It’s clearly not optimized for human reading on the server directly, but if you only have to do this once, or maybe need to parse a website in a script, that’s fine. It should work. Also check my tip at the end to remove all tags from the HTML file in one command.

Curl

Curl is another popular Linux command that does basically the same thing. There are way more features available with curl, but to download a simple HTML page, it’s almost the same.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

The main syntax is:
curl <url>

A first difference is that curl displays the HTML code directly on your screen, you need to redirect it if you want to save it in a local file:
curl <url> > myfile.html

From there, the result is the same as with “wget”. You get an HTML file, with the full source code of the page, and can use any editor or browser to open it.

The benefits of using curl over wget, is that it’s better suited for scripting (most languages have libraries for curl by the way), with many options allowing to access any website (skip HTTPS certificate check, send POST data, upload files, etc.).

Check the curl documentation here if you need more guidance, and here are, as an example, all the functions available in PHP to interface with curl. Most languages will have something similar.

Note: You can send the result of the curl request to a tool like html2text to remove the HTML tags for you, so you only see the readable texte, something like:
curl https://raspberrrytips.com | html2text
You may need to install it first with:
sudo apt install html2text

And if nothing works as expected, maybe you should consider installing a light GUI on your server.

If you liked this article, here are a few more tips about command lines on Linux that might be interesting to you:

Whenever you're ready, here are other ways I can help you:

Master Linux Commands: Overwhelmed with Linux commands? This book is your essential guide to mastering the terminal. It includes practical tips, real-world examples, and a bonus cheat sheet to keep by your side.

The RaspberryTips Community: Need help with Linux or want to chat with people who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct support (try it for just $1).

You can also find all my recommendations for tools and hardware on this page.

Similar Posts