lynx Command
The lynx command is a text-based web browser that runs in the terminal. It allows you to browse websites, follow links, download files, and navigate the web without a graphical interface, making it ideal for servers, automation, and accessibility.
Syntax
Description
The lynx browser is a fully-featured web browser that operates entirely in text mode. It supports HTML, forms, cookies, SSL, and many modern web features while maintaining a lightweight footprint.
Key features:
- Text-based web browsing
- Support for HTML, forms, and cookies
- SSL/HTTPS support
- File download capabilities
- Configurable user agent and settings
- Accessibility features for screen readers
- Scripting and automation support
Common Options
| Option | Description |
|---|---|
-dump |
Output page content as formatted text and exit |
-source |
Output raw HTML source and exit |
-listonly |
List only the links found in the page |
-crawl |
Output each page to a file and continue crawling |
-traversal |
Traverse all links from starting page |
-accept_all_cookies |
Accept all cookies without prompting |
-anonymous |
Apply anonymous restrictions (no downloads, etc.) |
-auth=id:pw |
Set authentication credentials |
-cfg=file |
Use specified configuration file |
-cookies |
Toggle cookie support |
-display=DISPLAY |
Set X display for external programs |
-editor=EDITOR |
Set external editor for forms |
-homepage=URL |
Set home page URL |
-mime_header |
Include MIME headers in output |
-nolist |
Don't list links at end of dump |
-useragent=string |
Set User-Agent header |
-width=N |
Set screen width for formatting |
Navigation Keys
| Key | Action |
|---|---|
Arrow Keys |
Navigate between links and text |
Enter |
Follow selected link |
Tab |
Move to next link |
Shift+Tab |
Move to previous link |
g |
Go to URL |
G |
Edit current URL |
h |
Help |
k |
Show keymap |
o |
Options menu |
p |
Print page |
q |
Quit |
r |
Reload page |
s |
Search in page |
u |
Go back |
v |
View bookmarks |
/ |
Search forward |
? |
Search backward |
Space |
Page down |
b |
Page up |
Examples
Basic web browsing
Open a website in interactive mode
Dump page content as text
Extract page content as formatted text
Get raw HTML source
Download raw HTML source code
List all links on a page
Extract all links from a webpage
Set custom user agent
Browse with custom User-Agent string
Accept all cookies
Accept cookies without prompting
Set output width
Format output for specific width
Save to file
Save page content to a file
Web Scraping and Automation
Content Extraction
Extract text content
Extract clean text content from web pages
Link extraction
Extract links and references from web pages
Batch Processing
Process multiple URLs
Process multiple URLs in batch
Web crawling
Crawl websites and extract content
Form Handling
Submit forms programmatically
Handle web forms (limited automation capabilities)
Configuration
Configuration Files
User configuration
Lynx configuration file locations
Common configuration options
Common configuration settings
Environment Variables
Useful environment variables
Environment variables affecting lynx behavior
Advanced Usage
Authentication
HTTP authentication
Handle HTTP authentication
SSL/HTTPS
SSL options
Handle SSL/HTTPS connections
Proxy Support
Using proxies
Browse through proxy servers
Practical Use Cases
System Administration
Monitor web services
Monitor web services and health checks
Download files
Browse and identify files for download
Content Analysis
SEO and content analysis
Analyze web page content and structure
Link analysis
Analyze links and link structure
Accessibility Testing
Text-only accessibility
Test website accessibility for text-based browsing
Scripting Examples
Website Monitoring Scripts
Website uptime checker
Monitor website availability and basic functionality
Content change detector
Detect changes in web page content
Data Extraction Scripts
News headline extractor
Extract headlines and summaries from news websites
Price monitoring
Monitor product prices and track changes
Troubleshooting
Common Issues
Installation issues
Install lynx on different operating systems
Display and encoding issues
Handle character encoding and display issues
Network and proxy issues
Troubleshoot network connectivity and proxy issues
Performance Issues
Slow loading pages
Handle slow-loading or heavy websites
Comparison with Other Tools
lynx vs curl/wget
| Feature | lynx | curl/wget |
|---|---|---|
| Purpose | Web browsing and content viewing | File downloading and HTTP requests |
| JavaScript | No support | No support |
| Forms | Interactive support | Manual POST data |
| Cookies | Automatic handling | Manual cookie jar |
| Content Rendering | Text formatting | Raw content |
When to use each tool
Choose the right tool for your specific needs
Best Practices
lynx Best Practices
- Respect Robots.txt - Check robots.txt before automated scraping
- Use Appropriate User-Agent - Identify your bot properly
- Rate Limiting - Add delays between requests to avoid overloading servers
- Handle Errors - Check exit codes and handle network failures gracefully
- Cache Results - Store results to avoid repeated requests
- Test Accessibility - Use lynx to test how your sites work without JavaScript