# Curl & Wget

1. A curl command is a command line tool that helps to transfer the data from server to client and vice versa.
    

Syntax: curl \[OPTIONS\] \[URL\]

By default curl is already installed in Linux.

Eg 1: If you want to see the content of website

`ubuntu@ip-172-31-35-243:~$ curl https://linux.org/`

Eg 2: You can save the content in other file.

`ubuntu@ip-172-31-35-243:~$ curl -o file1.txt https://linux.org/`

Eg 3: This command will download the file.txt from http://example.com and save it with the same file (file.txt) in the current directory

`curl -O http://example.com/file.txt`

Eg 4: It resumes the previously interrupted download. This is useful when the file download is incomplete and you want to resume the download where it was left.

`curl -C http://example.com/file.txt`

Eg 5: If http://example.com redirects to http://newsite.com, it will output the redirect message and not follow the new URL.

`curl http://example.com`

It will redirect to http://newsite.com and follow the content of redirect link

`curl -L http://example.com`

It fetches the HTTP headers of URL without downloading the actual content.

`curl -I http://example.com`

2. The wget (Web Get) command is used to download the file from server or retrieve the resources from web server. It fetches the data from URL
    

Syntax: wget \[OPTIONS\] \[URL\]

Eg 1: Download the file from the specified URL

`wget http://example.com/file1.txt` → save the file with file1.txt

Eg 2: If you want to save the file with other name

`wget -O local.txt http://example.com/file1.txt`

Eg 3: It will download the file from its subdirectories.

`wget -r http://example.com`

Eg 4: To limit the download speed

`wget —limit-rate=100k http://example.com/file.zip`
