Linux wget Command: Download Files from URLs

wget is a GNU tool for downloading files from URLs such as HTTP, HTTPS, and FTP. It is useful for saving files from a server or resuming interrupted downloads.

What is the wget command?

By default, it saves to the current directory using the remote file name. -O specifies the desired output file, and -c resumes an interrupted download. It also has a recursive download feature, but since it can request many pages, you should first check the scope and site policies.

Basic syntax

wget [options] URL

Installed implementations and options may vary depending on the distribution. Check the manual on your system with man wget.

Examples

Single file download

It saves to the current directory using the file name provided by the server.

wget https://example.com/

Specifying a file name

After confirming the possibility of overwriting an existing file, decide the save path.

wget -O example.html https://example.com/

Resume Interrupted Files

If the server supports range requests, it resumes at the end of the existing file.

wget -c https://example.com/archive.tar.gz

What should we check after downloading?

wget -O saves the received content to the specified filename. Depending on the server and network conditions, the progress or HTTP status messages may be displayed on standard error.

wget -O example.html https://example.com
ls -lh example.html

The second command shows the name and size of the file if it has been created. Size and content may vary each time you request, so don’t expect a fixed byte count.

A download success message alone does not guarantee the authenticity of the file. If it is an official distribution file, separately verify the checksum or signature provided by the provider. If you run it again with the same name, -O can overwrite the existing file, so check the save path first.

Main Options and Format

Options/Format Description
-O file Saves the download result to the specified file.
-P directory Specifies the directory to save to.
-c Resumes interrupted downloads when possible.
-q Reduces progress messages.
--spider Check the possibility of accessing a URL without saving the content.
-r Recursively fetch linked resources.

Precautions when using

-O can overwrite the specified file, so check existing data. When using -c, if the server file has changed, the resumed result can be corrupted, so checksum verification is important. Large-scale -r operations may put a burden on the server, so check permissions and scope.

Frequently Asked Questions

Does using wget -c always safely resume downloads?

No. It depends on whether the server supports range requests and whether the remote file has changed. Verify the checksum of the completed file.

Official Documentation

The exact behavior of the options and differences by implementation can be found in the official wget documentation.

More in This Category
Linux ssh-keygen Command: Generate SSH Keys and Inspect Fingerprints

Linux ssh-keygen Command: Generate SSH Keys and Inspect Fingerprints

Learn how to generate SSH Keys and Inspect Fingerprints with the Linux ssh-keygen command, including practical examples, key options, and important precautions.

Linux su Command: Switch User Accounts and Login Shells

Linux su Command: Switch User Accounts and Login Shells

Learn how to use the Linux su command to switch user accounts and start login or non-login shells, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux uname Command: Check Kernel and System Architecture

Linux uname Command: Check Kernel and System Architecture

Learn how to check Kernel and System Architecture with the Linux uname command, including practical examples, key options, and important precautions.

Linux alias Command: Create Command Shortcuts

Linux alias Command: Create Command Shortcuts

Learn how to use the Linux alias command to create, inspect, and make shell command aliases persistent, with essential options, practical examples, output interpretation, and common troubleshooting tips.

How to Check the Linux Distribution, Version, Kernel, and Architecture

How to Check the Linux Distribution, Version, Kernel, and Architecture

Learn how to identify a Linux distribution and version with /etc/os-release, then check the running kernel and CPU architecture with hostnamectl and uname. The guide also covers scripts, legacy systems, containers, WSL, and chroot environments.

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

Learn how to find Block-Device UUIDs and Filesystem Types with the Linux blkid command, including practical examples, key options, and important precautions.

Linux traceroute Command: Trace Routers on the Way to a Host

Linux traceroute Command: Trace Routers on the Way to a Host

Learn how to trace Routers on the Way to a Host with the Linux traceroute command, including practical examples, key options, and important precautions.

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Use pwd, ls, cd, and tree to find your current location, inspect directories, navigate paths, and check where each command takes you.

Linux realpath Command: Resolve Absolute and Canonical Paths

Linux realpath Command: Resolve Absolute and Canonical Paths

Learn how to use the Linux realpath command to resolve relative paths, symbolic links, and redundant path components, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux w Command: Show Logged-In Users and Their Processes

Linux w Command: Show Logged-In Users and Their Processes

Learn how to show Logged-In Users and Their Processes with the Linux w command, including practical examples, key options, and important precautions.