Progress: 0/62 (0%)

⬇️ Downloading Files (wget, curl)

Downloading Files

Sometimes you just need to grab files from the internet directly to your Linux system — like grabbing a PDF, script, or dataset. Two popular tools for this are wget and curl.

Using wget

wget
wget https://example.com/file.txt

This command downloads the file from the web and saves it in the current directory. By default, wget keeps retrying if the connection drops.

Useful options:

  • -O filename → save as a specific filename
wget -O myfile.txt https://example.com/file.txt
  • -q → quiet mode (no progress messages)
  • -c → continue partially downloaded files

Using curl

curl -O
curl -O https://example.com/file.txt

This command downloads the file from the web. The -O option preserves the original filename.

Useful options:

  • -o filename → save as a custom filename
curl -o myfile.txt https://example.com/file.txt
  • -L → follow redirects (if the link redirects somewhere else)

Key Difference Between wget and curl

  • wget → great for simple downloads and recursive downloading (entire directories).
  • curl → more flexible for scripting, uploading files, or interacting with APIs.

Pro tip

To test if your internet connection works while downloading, try:

wget https://www.google.com

or

curl -I https://www.google.com

The -I in curl fetches headers only, not the full page — a quick connectivity check.

Real-life analogy

Think of wget like sending a courier to fetch a package from a friend's house — it keeps trying until it successfully delivers. curl is like asking a friend for the file via email — they send it straight to you, and you can choose what name to save it as.