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 common 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.
-O forces a predictable
output path for scripts and pipelines.
-c continues from the current
local size when the server supports partial content.
-b detaches and writes output
to a log file you can review later.
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’.
The server may not support partial downloads, or the remote file changed. Remove the partial file and re-download, or use a different mirror if available.
Verify the URL and system time, and confirm the host is trusted. Certificate errors are often a sign of the wrong endpoint or a man-in-the-middle risk.
Check the log file and confirm the PID is still running. If the job exited, the log usually captures the reason.
Validate integrity with checksums or signatures when provided. If no checksum exists, re-download and compare sizes and hashes across attempts.
If this was a practice run, remove the downloaded artifacts and log so your working directory stays clean.
ls -la
rm -f sample.tar.gz custom.tar.gz wget-log
You can download with default naming, force an output name
with -O, resume a partial transfer with
-c, and confirm background activity via
wget-log.
wget: Download content from a URL to a file.
wget <URL>: Download to the current directory using the URL filename.
-O <file>: Write output to a specific filename.
-c: Continue an interrupted download if supported by the server.
-b: Run in the background and write output to wget-log.