Skip to content

Wget

125 commands

A non-interactive downloader for HTTP, HTTPS and FTP that can resume, retry and mirror entire websites recursively.

  • downloads
  • mirroring
  • HTTP

Install Wget

sudo apt install wget

Basic Usage7

wget https://example.com/file.txt

Downloads a single file from a URL and saves it to the current directory.

wget -O output.txt https://example.com/file.php?id=1

Downloads a file and saves it with a specific custom filename.

Link
wget -P /tmp/downloads https://example.com/image.jpg

Downloads a file and saves it to a specific directory path.

Link
wget -i urls.txt

Downloads multiple files sequentially from a list of URLs contained in a text file.

Link
wget --no-clobber https://example.com/file.zip

Skips the download if the file already exists locally.

Link
wget -c https://example.com/large.iso

Resumes a partially downloaded file from where it left off.

Link
wget -B https://example.com/ -i relative_urls.txt

Resolves relative URLs in an input file against a specified base URL.

Link

Download Resilience5

wget --tries=10 https://example.com/unstable.file

Sets the maximum number of retries for a failed download attempt.

Link
wget --tries=inf https://example.com/critical.service

Retries the download infinitely until successful.

Link
wget --timeout=60 https://example.com/slow.resource

Sets the network read timeout in seconds to prevent hanging connections.

Link
wget --connect-timeout=10 https://example.com

Sets the timeout specifically for the initial connection establishment.

Link
wget --waitretry=5 https://example.com/file

Waits for a specified number of seconds between retry attempts.

Link

Logging and Output6

wget -o download.log https://example.com/file.txt

Redirects all operational messages and errors to a log file instead of stdout.

Link
wget -a download.log https://example.com/file2.txt

Appends operational messages to an existing log file.

Link
wget -q https://example.com/silent_script.sh

Runs in quiet mode with absolutely no output to the terminal.

Link
wget -nv https://example.com/report.pdf

Runs in non-verbose mode, printing only basic status lines and errors.

Link
wget -b https://example.com/huge_dataset.csv

Goes to background immediately after startup and writes output to wget-log.

Link
wget --progress=bar:force https://example.com/file

Forces a specific type of progress bar display even if stderr is not a terminal.

Link

Bandwidth and Networking7

wget --limit-rate=200k https://example.com/movie.mp4

Limits the download speed to 200 kilobytes per second to save bandwidth.

Link
wget -w 10 https://example.com/file

Waits the specified number of seconds between multiple file retrievals.

Link
wget --random-wait -w 10 -i list.txt

Waits a random interval between 0.5 and 1.5 times the specified wait value to simulate human behavior.

Link
wget --bind-address=192.168.1.5 https://example.com

Binds the client socket to a specific local IP address on a multi-interface system.

Link
wget -4 https://example.com

Forces the connection to use IPv4 addresses only.

Link
wget -6 https://example.com

Forces the connection to use IPv6 addresses only.

Link
wget --no-dns-cache https://example.com

Disables DNS caching to force a new lookup for every request.

Link

HTTP Headers and User Agent3

wget --user-agent="Mozilla/5.0" https://example.com

Spoofs the User-Agent header to identify as a specific browser or bot.

Link
wget --header="Accept: application/json" https://example.com/api

Adds a custom HTTP header to the request.

Link
wget --referer="https://google.com" https://example.com/hidden

Sets the HTTP Referer header to simulate clicking a link from another site.

Link

Authentication6

wget --user=admin --password=secret https://example.com/protected

Uses basic HTTP authentication with provided username and password.

Link
wget --ask-password --user=admin https://example.com/protected

Prompts the user to enter the password interactively to avoid recording it in history.

Link
wget --auth-no-challenge --user=admin --password=pass https://example.com

Sends authentication credentials immediately without waiting for a server challenge.

Link
wget --header="Authorization: Bearer <token>" https://api.example.com/v1/data

Authenticates using a Bearer token in the Authorization header.

Link
wget --http-user=user --http-password=pass https://example.com

Explicitly sets HTTP authentication separate from FTP authentication options.

Link
wget --ftp-user=user --ftp-password=pass ftp://example.com

Explicitly sets FTP authentication separate from HTTP authentication options.

Link

Session Management2

wget --save-cookies cookies.txt --keep-session-cookies https://example.com/login

Saves the cookies received from the server, including session cookies, to a file.

Link
wget --load-cookies cookies.txt https://example.com/dashboard

Loads cookies from a file to maintain a session across multiple requests.

Link

Proxy Configuration4

wget -e use_proxy=yes -e http_proxy=127.0.0.1:8080 https://example.com

Configures a specific HTTP proxy for the connection using command line execution.

Link
wget --proxy-user=user --proxy-password=pass https://example.com

Provides credentials for authenticating with the proxy server itself.

Link
wget --no-proxy https://internal.example.com

Explicitly bypasses proxy settings for specific requests.

Link
wget --no-proxy --header="Host: internal.test" https://127.0.0.1

Directly accesses a localhost service with a spoofed Host header, bypassing proxies.

Link

SSL and Security6

wget --no-check-certificate https://self-signed.local

Skips SSL certificate validation, useful for self-signed certificates in labs.

Link
wget --secure-protocol=TLSv1_2 https://example.com

Forces the connection to use a specific version of the TLS protocol.

Link
wget --certificate=client.pem --private-key=key.pem https://mtls.example.com

Uses a client-side certificate and private key for mutual TLS (mTLS) authentication.

Link
wget --ca-certificate=rootCA.pem https://internal.lab

Verifies the server's certificate against a specific custom CA file.

Link
wget --secure-protocol=PFS https://example.com

Enforces Perfect Forward Secrecy or allows automatic protocol negotiation.

Link
wget --https-only -r https://example.com

When recurring, only follows links that use the HTTPS protocol.

Link

Recursive Operations10

wget -r https://example.com/directory/

Recursively downloads files and subdirectories from the specified URL.

Link
wget -r -l 2 https://example.com

Recursively downloads with a maximum depth limit.

Link
wget -m https://example.com

Mirrors a website (enables recursion, time-stamping, and infinite depth).

Link
wget -r -k https://example.com

Recursively downloads and converts links to point to local files for offline viewing.

Link
wget -p https://example.com/page.html

Downloads all files necessary to display the HTML page (images, CSS, JS).

Link
wget -mpk https://example.com

Combines mirror, page requisites, and link conversion for a complete offline backup.

Link
wget -r --level=inf https://example.com

Recurses with infinite depth (use with extreme caution).

Link
wget -r --accept-regex 'index\.(html|php)' https://example.com

Recursively downloads only index files or specific dynamic pages via regex.

Link
wget -r --delete-after https://example.com

Downloads files recursively to warm up a cache or test throughput, then deletes them.

Link
wget -r -k -p -E https://example.com

The most robust set of flags for ensuring a mirrored HTML page renders correctly offline.

Link

Directory Control4

wget -r -nd https://example.com/files/

Recursively downloads files but saves them all to the current directory, flattening the structure.

Link
wget -r --no-parent https://example.com/pub/data/

Recursively downloads but prevents ascending to parent directories.

Link
wget -r --no-host-directories https://example.com

Recursively downloads but skips creating a directory named after the hostname.

Link
wget -r --no-host-directories --cut-dirs=1 https://example.com/user/files/

Combines host skipping and directory cutting for a clean local folder structure.

Link

Filtering and Parsing4

wget -r -A pdf,docx https://example.com/documents/

Recursively downloads only files matching the specified extensions.

Link
wget -r -R index.html,robots.txt https://example.com

Recursively downloads while explicitly excluding specified filenames or extensions.

Link
wget -r --accept-regex "/2023/.*\.pdf" https://example.com/archive/

Uses a regular expression to filter which URLs should be downloaded during recursion.

Link
wget --ignore-case -A JPEG,jpg https://example.com/photos

Matches file extensions case-insensitively during filtering.

Link

Advanced Interactions6

wget --post-data="id=5&action=delete" https://example.com/api.php

Sends data to the server using the HTTP POST method.

Link
wget --post-file=payload.json --header="Content-Type: application/json" https://example.com/api

Uploads the contents of a file via HTTP POST with appropriate headers.

Link
wget --method=PUT --body-file=update.json https://example.com/resource/1

Uses a specific HTTP verb (like PUT or DELETE) to interact with RESTful APIs.

Link
wget --content-disposition https://example.com/download?id=123

Honors the Content-Disposition header sent by the server to name the saved file.

Link
wget --spider https://example.com/file

Checks if the file exists without downloading it (HEAD request).

Link
wget -O - https://example.com/script.sh | bash

Downloads a file to standard output for immediate piping into another command.

Link

FTP Support3

wget ftp://user:password@ftp.example.com/file.txt

Downloads a file using the FTP protocol with authentication.

Link
wget --glob=on ftp://ftp.example.com/pub/*.txt

Uses wildcard globbing to download multiple files via FTP.

Link
wget --no-passive-ftp ftp://ftp.example.com/file

Forces active FTP mode instead of passive mode.

Link

Red Team and Recon9

wget --spider -r -nd --no-parent https://example.com 2>&1 | grep 'Broken link'

Crawls a site without downloading to identify broken links and potential hijackable assets.

Link
wget -r -l 5 --spider --force-html -i input.html

Forces wget to treat an input file as HTML to parse and follow links within it.

Link
wget --user-agent=" " https://example.com

Sends an empty User-Agent string to test server behavior for unknown clients.

Link
wget --header="X-Forwarded-For: 127.0.0.1" https://example.com

Injects headers attempting to bypass IP-based access controls.

Link
wget --execute robots=off -r https://example.com/admin

Ignores the robots.txt file to crawl paths specifically disallowed by the administrator.

Link
wget -r -A config,conf,cfg,ini,env,sh,bak,sql https://example.com

Recursively scans for sensitive configuration and backup files left on the server.

Link
wget --spider --no-check-certificate https://192.168.1.1/admin

Probes an internal IP endpoint for existence ignoring SSL errors.

Link
wget --method=OPTIONS -S https://example.com

Sends an HTTP OPTIONS request to discover allowed methods on the server.

Link
wget --method=TRACE -S https://example.com

Sends a TRACE request to debug upstream proxies or test for Cross-Site Tracing (XST).

Link

Blue Team and Forensics6

wget --warc-file=evidence --warc-cdx -m https://malicious-site.com

Mirrors a site and saves the request/response data into a WARC archive for forensic evidence.

Link
wget --server-response --spider https://example.com

Prints the full HTTP headers sent by the server to analyze security headers.

Link
wget --timestamping https://example.com/daily_log.txt

Downloads the file only if the server version is newer than the local version.

Link
wget --preserve-permissions https://example.com/script.sh

Preserves the file permissions of the downloaded file as they are on the remote server.

Link
wget --max-redirect=0 https://example.com/redirect

Prevents wget from following redirects to analyze the initial redirect destination.

Link
wget --content-on-error https://example.com/error_page

Saves the body of the response even if the server returns a 4xx or 5xx error code.

Link

Performance Tuning5

wget --no-cache https://example.com/live_data

Ensures the server sends a fresh version of the data rather than a cached copy.

Link
wget --local-encoding=UTF-8 --remote-encoding=ISO-8859-1 https://example.com

Handles encoding differences between the local system and the remote server.

Link
wget --unlink https://example.com/file

Unlinks (deletes) the file before writing the new download, preventing symlink attacks.

Link
wget --backups=1 https://example.com/config.xml

Rotates existing files by adding a .1 suffix instead of overwriting them.

Link
wget --inet4-only --bind-address=127.0.0.1 https://localhost/test

Combinatory command forcing IPv4 and a specific interface binding.

Link

Advanced Workflow18

wget --load-cookies=cookies.txt --post-data "download=true" -O - https://example.com/export | gzip > dump.gz

Authenticates, requests a POST export, streams to stdout, and compresses immediately.

Link
wget -r -l 1 --no-parent -A.txt -H -D example.com,cdn.example.com https://example.com

Recursively downloads with host spanning enabled but restricted to specific domains.

Link
wget --regex-type=posix --accept-regex '.*\.(jpg|png)' https://example.com

Specifies the regular expression type (POSIX or PCRE) for advanced filtering.

Link
wget --no-if-modified-since https://example.com/data

Forces a download even if the server claims the file has not been modified.

Link
wget --crl-file=crl.pem https://secure.example.com

Checks the server certificate against a Certificate Revocation List (CRL).

Link
wget --random-wait --limit-rate=100k --user-agent="Mozilla/5.0" -e robots=off -m https://example.com

A 'stealthy' mirror workflow attempting to evade detection by acting like a slow human browser.

Link
wget -O /dev/null https://example.com/speedtest.bin

Downloads a file and discards it immediately to test network throughput.

Link
wget --force-directories -i list.txt

Forces the creation of a hierarchy of directories even if one would not normally be created.

Link
wget --protocol-directories -r https://example.com

Uses the protocol name as a directory component when saving files locally.

Link
wget --cut-dirs=2 -r https://example.com/dir1/dir2/data/

Ignores the specified number of parent directory components when saving files.

Link
wget --adjust-extension -r https://example.com/cgi-bin/script

Appends the proper extension (like .html) to files downloaded with unknown content types.

Link
wget --restrict-file-names=windows https://example.com/aux.txt

Escapes characters in filenames to ensure compatibility with specific operating systems.

Link
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://example.com/wiki/

The ultimate 'make a local copy of this documentation section' command.

Link
wget --header="Cookie: session=123" https://example.com/admin

Manually sets the Cookie header without loading from a file.

Link
wget --start-pos=1000 https://example.com/file.txt

Starts the download from a specific byte offset.

Link
wget --no-cookies --header "Cookie: auth=token" https://example.com

Prevents wget from using its internal cookie jar, relying manual headers.

Link
wget --body-data="param=value" --method=POST https://example.com/api

Alternative way to send data strings with specific methods.

Link
wget --compression=auto https://example.com/data

Asks the server to compress the response (gzip) to save bandwidth.

Link

Debugging1

wget -d https://example.com

Prints extensive debug output to the terminal (requires wget compiled with debug support).

Link

Filtering4

wget -r --exclude-domains facebook.com,twitter.com https://example.com

Follows links but explicitly avoids downloading content from specific excluded domains.

Link
wget -r --follow-tags=a,img,link https://example.com

Only parses and follows links found within specific HTML tags.

Link
wget -r --ignore-tags=area,form https://example.com

Parses the document but ignores links found within specific HTML tags.

Link
wget --span-hosts -r https://example.com

Allows recursion to jump to foreign hosts (use with caution and filters).

Link

Output Control3

wget --no-http-keep-alive https://example.com

Disables HTTP Keep-Alive, forcing a new TCP connection for every file.

Link
wget -O- https://example.com/logs.txt | grep error

Uses standard output strictly for piping data into text processing tools.

Link
wget --ask-password --output-file=/dev/stderr https://example.com/secret

Forces log output to standard error specifically.

Link

Network Tuning1

wget --retry-connrefused -t 5 https://example.com

Considers 'Connection Refused' as a transient error and retries.

Link

Meta2

wget --version

Displays the version of wget and the compilation options.

Link
wget --help

Displays the help message with a summary of available options.

Link

Logging1

wget --no-verbose --show-progress https://example.com/file

Keeps the log quiet but still displays the progress bar on the terminal.

Link

Security Testing1

wget --ciphers=DEFAULT:!AES https://example.com

Specifies the GnuTLS cipher priority string to test server SSL/TLS configurations.

Link

Cleanup1

wget --no-hsts https://example.com

Prevents wget from creating or updating the HSTS (HTTP Strict Transport Security) database file.

Link