Home / Alt manpages / lynx(1)

  • lynx(1)
  • User command
  • linux

Browse and Extract Web Pages from a Terminal with Lynx

You will use Lynx 2.9.0 to open a web page interactively, follow links with the keyboard, and produce a readable or raw extract for a shell pipeline. Allow about 15 minutes for a first pass. The examples use ordinary user privileges and do not change system configuration.

1. Check the installed build

Lynx is a text browser for terminal displays. This guide targets the Ubuntu package installed on this machine, lynx-common 2.9.0rel.0-2build2. The upstream project currently lists 2.9.3 as its most recent stable release, so keep the installed version in mind when comparing behaviour with another system.

$ command -v lynx
/usr/bin/lynx
$ lynx -version
Lynx Version 2.9.0 (15 Jan 2024)
libwww-FM 2.14, SSL-MM 1.4.1, GNUTLS 3.8.3, ncurses 6.4.20240113(wide)
Built on linux-gnu.

Read the local option list when you need a switch not covered here:

$ lynx -help

Checkpoint

You have a working lynx binary and know which version you are testing.

Give Lynx an HTTP or HTTPS URL. It starts an interactive curses session in the current terminal.

$ lynx https://example.com

Use the Up and Down arrow keys to move between highlighted links. Press Return or the Right arrow to follow the selected link. Press the Left arrow, or u, to retreat. Press H, ?, or F1 for Lynx's own help. Press Delete to view the history list.

Terminal display problems are usually terminal-type problems, not web-page problems. Check TERM first. For a remote execution context, you can tell Lynx which terminal type to assume:

$ echo "$TERM"
xterm-256color
$ lynx -term=xterm-256color https://example.com

Do not copy a made-up terminal value from a different machine. Use a value supported by the terminal database on the system where Lynx runs.

3. Dump readable text without opening the interface

Use -dump when the result belongs in a log, a review, or another command. Lynx formats the document and writes it to standard output before exiting. Unlike interactive mode, it processes all documents named on the command line.

$ lynx -dump https://example.com
Example Domain

   This domain is for use in documentation examples without needing
   permission. Avoid use in operations.

   [1]Learn more

References

   1. https://iana.org/domains/example

The exact wording of a remote page can change. The useful checks are a successful exit status and readable output, not a fixed number of lines. Set a different formatting width when a narrow or wide report is easier to read:

$ lynx -dump -width=120 https://example.com > example.txt
$ test -s example.txt && echo "saved readable output"
saved readable output

Shell redirection replaces an existing example.txt before Lynx starts. Choose a new filename if the old report matters. If the command fails, inspect the exit status and the terminal error before treating an empty or partial file as valid.

Checkpoint

example.txt is non-empty and contains the page text. The source page remains unchanged.

4. Inspect HTML source

Use -source instead of -dump when you need the response's HTML rather than Lynx's formatted interpretation. This is useful for checking links, metadata, or markup.

$ lynx -source https://example.com > example.html
$ head -n 5 example.html

The manual says files with standard web suffixes such as .html are treated as HTML. For a local file with another suffix, add -force_html when that is genuinely what the file contains:

$ lynx -source -force_html /path/to/page.data > page-source.html

Do not confuse -source with a security scanner. It retrieves and prints content; it does not prove that the markup is safe to render elsewhere.

5. Keep local execution disabled

The installed help reports -noexec as the default. It disables local program execution. Keep that default for ordinary browsing, especially when opening unfamiliar local content.

$ lynx -noexec https://example.com

Safety boundary

-exec enables local program execution and is normally not configured. Do not add it merely because a page contains a link that does not work. If you inherit a script or wrapper that enables it, stop and review the page source, the wrapper, and the execution restrictions first. Lynx also has -validate, which accepts only HTTP URLs and applies additional security restrictions. That is a useful constrained mode for checking web links:

$ lynx -validate -dump https://example.com

6. Treat forms and credentials as state-changing actions

Lynx can submit form data non-interactively. -get_data sends a GET request and -post_data sends a POST request. In both cases, data is read from standard input until a line beginning with three hyphens. A POST can create, edit, or delete something on the remote service.

Warning

Do not paste real passwords, access tokens, or production form data into a shell command or an unreviewed script. Command arguments and redirected input may be exposed through process or shell history. The manpage provides - as an option-input mechanism, but that is not a substitute for reviewing the endpoint and data.

For a harmless test endpoint that you own, the shape is:

$ lynx -post_data https://forms.example.invalid/submit <<'FORM'
name=TEST-VALUE
---
FORM

This example is deliberately not expected to connect. Replace the URL only with a service whose request method, fields, and side effects you have verified. Prefer interactive review before sending a real form.

7. Use configuration and proxies deliberately

Lynx reads configuration from its normal lynx.cfg search path. LYNX_CFG can override the global configuration filename, and LYNX_CFG_PATH can override the configuration search path. WWW_HOME overrides the configured startup URL. Check the effective settings without opening a page:

$ lynx -show_cfg

For network routing, the program recognises protocol-specific proxy variables such as http_proxy, https_proxy, and no_proxy. A SOCKS5 proxy can be supplied with -socks5_proxy=PROXY-HOST:1080 or SOCKS5_PROXY. Confirm the proxy policy before using it with authenticated or private URLs.

Done means

  • lynx -version identifies the installed build, and lynx -help is available for version-specific options.
  • You can open a URL interactively and navigate with arrows, Return, Left arrow, and u.
  • -dump produces readable text, while -source preserves HTML for inspection.
  • Output redirection uses a deliberate destination and does not silently destroy a useful report.
  • -noexec remains enabled, and form submission is treated as a reviewed, potentially state-changing request.