wget and curl: File Downloads

07 Nov 2026, 15:06:29
In Linux, the wget and curl command-line utilities are commonly used to download files from the internet and other servers. They allow you to download archives, installation packages, scripts, operating system images, and other files directly from the terminal without using a web browser.
Both utilities support HTTP and HTTPS, but they differ in some features and syntax.
In this article, we will look at how to install and use wget and curl to download files on a Linux server.

Checking whether wget and curl are installed

Before using these utilities, make sure they are installed.
To check whether wget is available:
wget --versionTo check whether curl is available:
curl --versionIf a command is not found, install the corresponding utility.
Debian / Ubuntu:
apt update
apt install wget curl -y
CentOS / AlmaLinux / Rocky Linux:
dnf install wget curl -yFor older CentOS versions, you can use yum:
yum install wget curl -y

Downloading files with wget

The simplest way to download a file is to specify its direct URL:
wget https://example.com/file.zipThe file will be downloaded to the current directory with the name file.zip.

Specify a filename when downloading

If you need to save the file under a different name, use the -O option:
wget -O archive.zip https://example.com/file.zip

Download a file to a specific directory

Use the -P option to specify the destination directory:
wget -P /root/downloads/ https://example.com/file.zipThe file will be saved in /root/downloads/.

Resume an interrupted download

If a download is interrupted, you can resume it from where it stopped:
wget -c https://example.com/file.zipThis is particularly useful when downloading large files.

Download a file in the background

To start a download in the background, use the -b option:
wget -b https://example.com/file.zipDownload progress information will be written to the wget-log file.

Limit the download speed

To limit the download speed, use --limit-rate:
wget --limit-rate=5m https://example.com/file.zipIn this example, the download speed is limited to approximately 5 MB/s.

Downloading files with curl

The curl utility can also download files over HTTP and HTTPS.
To save a file using its original filename, use the -O option (uppercase O):
curl -O https://example.com/file.zip

Specify a filename when downloading

To save a file under a specific name, use the -o option (lowercase o):
curl -o archive.zip https://example.com/file.zip

Download a file to a specific directory

Specify the full path using the -o option:
curl -o /root/downloads/file.zip https://example.com/file.zip

Resume an interrupted download

To resume an interrupted download, use the -C - option:
curl -C - -O https://example.com/file.zipNote that the server must support resuming downloads (HTTP Range).

Display download progress

With curl, you can display a detailed progress indicator:
curl -# -O https://example.com/file.zip

Limit the download speed

Use --limit-rate to limit the download speed:
curl --limit-rate 5M -O https://example.com/file.zipIn this example, the download speed is limited to approximately 5 MB/s.

Downloading files with redirects (Redirect)

Some servers redirect requests to another URL. This may happen when downloading files from websites that use a CDN or a file hosting service.
wget usually follows redirects automatically.
With curl, you need to add the -L option:
curl -L -O https://example.com/file.zipIf you need to save the file under a specific name:
curl -L -o archive.zip https://example.com/file.zip

Downloading files with authentication

If downloading a file requires HTTP Basic Authentication, you can provide a username and password.
Using wget:
wget --user=username --password=password https://example.com/file.zipUsing curl:
curl -u username:password -O https://example.com/file.zipWhen using these commands, keep in mind that the password may be stored in your shell history and visible in the process list. For more secure operation, use an interactive password prompt or protected configuration files.

Downloading a file from a non-standard port

If the web server runs on a non-standard port, you must specify the port in the URL.
For example, to download a file from port 8080:
wget http://192.168.1.100:8080/file.zipThe equivalent command using curl is:
curl -O http://192.168.1.100:8080/file.zip

Downloading files over HTTPS with SSL verification

When downloading files over HTTPS, both utilities verify the server's SSL certificate.
If the certificate is invalid or cannot be verified, the download may fail.
In wget, use the following option to disable certificate verification:
wget --no-check-certificate https://example.com/file.zipIn curl:
curl -k -O https://example.com/file.zipImportant: Disabling certificate verification reduces connection security. Use these options only for troubleshooting or in a controlled environment. It is preferable to fix the certificate or certificate chain issue instead.

Downloading multiple files with wget

Specify multiple URLs in a single command

wget https://example.com/file1.zip https://example.com/file2.zip https://example.com/file3.zipFiles will be downloaded sequentially.

Use a list of URLs from a text file

Create a file named urls.txt:
https://example.com/file1.zip
https://example.com/file2.zip
https://example.com/file3.zip
Start the download:
wget -i urls.txt

Download multiple files in parallel

To download several files simultaneously, you can use the -P option together with xargs:
cat urls.txt | xargs -n 1 -P 4 wgetHere:
-n 1 — pass one URL to each command.
-P 4 — run up to four processes simultaneously.

Downloading multiple files with curl

Specify multiple URLs in a single command

curl -O https://example.com/file1.zip -O https://example.com/file2.zip -O https://example.com/file3.zipThe -O option saves each file using its original filename.

Use a list of URLs from a text file

curl -K urls.txtThe urls.txt file must contain curl configuration options:
remote-name-all
url = "https://example.com/file1.zip"
url = "https://example.com/file2.zip"
url = "https://example.com/file3.zip"

Download files in parallel

cat urls.txt | xargs -n 1 -P 4 curl -OFile urls.txt:
https://example.com/file1.zip
https://example.com/file2.zip
https://example.com/file3.zip

-P 4 allows up to four downloads to run simultaneously.
Important: When downloading files in parallel, consider your network bandwidth and server load. You can change the number of simultaneous processes, for example, to -P 2 or -P 8.

How to check a downloaded file

After the download is complete, it is recommended to check that the file exists and verify its size.
To list the contents of the current directory:
ls -lhTo check the size of a specific file:
du -h file.zipTo verify file integrity, you can calculate its SHA256 checksum:
sha256sum file.zipCompare the resulting checksum with the one published by the download source.

Comparison of wget and curl

Featurewgetcurl
HTTP / HTTPSYesYes
Saving filesYesYes
Resuming downloads-c-C -
Following redirectsAutomatically-L
Speed limiting--limit-rate--limit-rate
Background downloads-bNo built-in equivalent
HTTP requests and APIsLimitedYes
Downloading multiple filesYesPossible

Conclusion

wget and curl are useful tools for system administrators, allowing them to download files directly from a Linux server.
wget is convenient for downloading files, retrieving multiple resources, and resuming interrupted downloads.
curl provides more extensive capabilities for working with HTTP requests, APIs, headers, and redirects.
Both utilities are part of the standard toolkit recommended for every Linux server.

SSD Storage VPS

Browse Configurations

Windows SSD Storage VPS

Browse Configurations

Premium Dedicated Servers

Browse Configurations