ToolXON Blog

Wget Commands

wget commands: Wget helps download files and retrieve web resources from a terminal. This guide covers safe single-file downloads, resuming, status checks and limited recursion. This guide explains what each command does, its syntax, practical examples, useful options, and common mistakes. Commands are shown for typical installations; flags can vary across operating-system and tool versions.

Before you start

Open a terminal appropriate for the operating system shown in the examples. Check that the required tool is installed and that you are running it with the permissions needed for your task. Replace sample names, paths, hostnames and IDs with values from your own environment.

Syntax at a glance

Square brackets usually indicate optional arguments, while uppercase words such as FILE, HOST and PACKAGE are placeholders that you replace. Keep quotes around paths or text that contains spaces. Commands should be tested on a safe sample before being used in production.

Quick command reference

CommandWhat it doesExampleUseful options
wget URLDownload a file from a URLwget https://example.com/archive.zip-O FILE chooses the output name; -c resumes a partial download
wget -cResume a compatible interrupted downloadwget -c https://example.com/large.isoServer must support range requests for reliable resuming
wget -OWrite the response to an explicit filenamewget -O guide.pdf https://example.com/guide.pdfUse -O - to write to standard output
wget --spiderCheck whether a URL is reachable without saving itwget --spider https://example.com/-S displays server response headers
wget -rDownload linked files recursivelywget -r -l 1 https://example.com/docs/-l sets link depth; --no-parent limits traversal above the directory

Command syntax and examples explained

1. wget URL

Purpose: Download a file from a URL.

Syntax

wget [OPTIONS] URL

Example

wget https://example.com/archive.zip

Options and notes: -O FILE chooses the output name; -c resumes a partial download.

Confirm the download source before opening executables or archives.

2. wget -c

Purpose: Resume a compatible interrupted download.

Syntax

wget -c URL

Example

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

Options and notes: Server must support range requests for reliable resuming.

If the remote file changed, restarting may be safer than resuming.

3. wget -O

Purpose: Write the response to an explicit filename.

Syntax

wget -O FILE URL

Example

wget -O guide.pdf https://example.com/guide.pdf

Options and notes: Use -O - to write to standard output.

The specified file may be overwritten.

4. wget --spider

Purpose: Check whether a URL is reachable without saving it.

Syntax

wget --spider URL

Example

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

Options and notes: -S displays server response headers.

Some servers block spider-like requests or require authentication.

5. wget -r

Purpose: Download linked files recursively.

Syntax

wget -r [OPTIONS] URL

Example

wget -r -l 1 https://example.com/docs/

Options and notes: -l sets link depth; --no-parent limits traversal above the directory.

Use a narrow depth and respect site terms, robots rules and rate limits.

Common mistakes and troubleshooting

  • Command not found: confirm the tool is installed and available on your PATH; open a new terminal after changing PATH.
  • Permission denied: verify the current account, file permissions and target path. Use administrator/root privileges only when genuinely required.
  • Unexpected output: check the command version, quoting, current directory and exact arguments. Consult the local help or manual for options supported by your build.
  • Destructive operations: preview the target and keep a backup before deleting data, rewriting history, flashing a partition or changing system configuration.

Safety tips

Review every command before running it, especially commands that delete files, change permissions, flash firmware, alter a database or expose a network service. For network scanning and remote administration, work only on devices and systems you own or are authorized to test. Keep credentials, private keys, access tokens and log files private.

Frequently asked questions

Do these commands work on every system?

Not always. Some commands are specific to Windows, Linux, Android, a particular package manager or an installed tool version. Use the syntax shown for your platform and check local help when a flag is unavailable.

Can I copy and run every example exactly?

Use the examples as templates. Replace placeholders such as filenames, package IDs, hostnames and paths with your own values, and verify the effect before executing a command that changes data or system state.

Conclusion

Use this reference as a starting point, then confirm flags in the tool’s official help or manual for your installed version. A clear understanding of syntax, options and side effects makes command-line work more reliable.