how to access website from linux terminal

3 Best Ways to Access a Website in a Linux Terminal

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.

Linux doesn’t have to be intimidating. With my e-book, Master Linux Commands, you’ll uncover the secrets of the terminal in a fun, step-by-step journey. From basics to scripts, get ready to level up your Linux skills. Oh, and did I mention the handy cheat sheet you get as a bonus?

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.

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.).

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

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.

Join Our Community!

Connect, learn, and grow with other Raspberry Pi enthusiasts. Support RaspberryTips and enjoy an ad-free reading experience. Get exclusive monthly video tutorials and many other benefits.

Learn more

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.

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:

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

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.

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

Option 3: Download the web page

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.

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:

Your Go-To Linux Command Reference!
Download your exclusive free PDF containing the most useful Linux commands to elevate your skills!
Download now

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

Want to chat with other Raspberry Pi enthusiasts? Join the community, share your current projects and ask for help directly in the forums.

Additional Resources

Overwhelmed with Linux commands?
My e-book, “Master Linux Commands”, is your essential guide to mastering the terminal. Get practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
Grab your copy now.

VIP Community
If you just want to hang out with me and other Linux fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Python is a great language to get started with programming on any Linux computer.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

Similar Posts