Download files from a URL using wget, control the
output filename, and recover safely from interrupted transfers.
Run long downloads in the background while preserving logs for
verification.
You need to download a software package from the internet. Your task is to fetch a tarball from a URL, save it with a custom name, resume a partial download, and run a download in the background while capturing output for later review.
wget is commonly used in build pipelines and
on minimal servers where a browser is not available. Being
able to resume transfers and background long downloads keeps
maintenance work reliable over unstable connections.
wget.-O.
-c.-b and
validate where output is written.
wget <URL>.
wget -O.
wget -c.
wget -b
and reviewing wget-log.
wget https://example.com/sample.tar.gz
This downloads the remote file into the current directory using the filename from the URL path.
--2025-01-01 10:00:00-- https://example.com/sample.tar.gz
Resolving example.com (example.com)... 93.184.216.34
Connecting to example.com... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10240 (10K) [application/x-gzip]
Saving to: ‘sample.tar.gz’
sample.tar.gz 100%[===================>] 10.00K --.-KB/s in 0.02s
wget -O custom.tar.gz https://example.com/sample.tar.gz
Use -O when you need a predictable output name,
such as scripting downloads for automation.
Saving to: ‘custom.tar.gz’
custom.tar.gz 100%[===================>] 10.00K --.-KB/s in 0.02s
wget -c https://example.com/sample.tar.gz
If the local file exists and is incomplete,
-c requests remaining bytes instead of restarting
from the beginning.
Resuming download of ‘sample.tar.gz’.
HTTP request sent, awaiting response... 206 Partial Content
Length: 10240 (remaining: 2048)
sample.tar.gz 100%[+++++++++++++++++++] 2.00K --.-KB/s in 0.01s
wget -b https://example.com/sample.tar.gz
Background mode is useful when you want to continue working
while the download runs. Output is written to
wget-log by default.
Continuing in background, pid 12345.
Output will be written to ‘wget-log’.
wget <URL>
: Downloads a file from the provided URL to the current
directory.
-O <file>
: Writes output to a specific filename instead of the name
in the URL.
-c
: Continue an interrupted download by requesting remaining
bytes.
-b
: Run in the background and write output to
wget-log.