Using curl command in Linux

The curl command in Linux is used to download or upload data from or to a server by using one of the supported protocols which include HTTP, HTTPS, FTP, SCP, SFTP, etc. By using options you can resume the data transfer, limit the bandwidth, enable the user authentication, etc.

In this article, we will discuss the usage of the curl command in a Linux system.

How to install curl in Linux

On most of the Linux distributions, it comes preinstalled. If it is not in your system you can use on of the following command to install it –

To install on Ubuntu/Debian/ Linux Mint etc use –

sudo apt install curl

Or if you are using CentOS/RHEL then use –

sudo yum install curl

For installing in Fedora use –

sudo dnf install curl

How to use curl command in Linux

The syntax of using the curl command in Linux is given below –

curl [options] URL

You can find the options on the command’s manual page.

How to download a file

Use option -O or -o with the curl command to download a file. Using option -O will save the file in the current working directory while using -o will ask you the name and the location where the file is to be saved.

For example, to download the firefox browser, we will use –

curl -O

OR by using the option -o (in small) you can specify the location and filename of the file that is to be downloaded.

curl -o firefox.tar.bz2

How to resume an interrupted download

You can resume an interrupted download by specifying -C this will tell curl to automatically find out where/ how to resume the transfer. Now suppose the Mozilla firefox file is interrupted while downloading with the curl command by pressing ctrl+c.

This file can be resumed by using the following command –

curl -C - -O

Downloading multiple files with the curl command

You can specify multiple URLs with the option-O if you want to download multiple files. For example to download two files names.html and about.html from the URL use –

 curl -O -O

How to upload a file to an FTP server

A file can be uploaded to an FTP server by using the following command –

curl -u username:password -T filename ftp://ftp_server_url

Where username and password are login credentials to the FTP server.

Replace the filename with the actual name of a file and the ftp_server_url with the server’s URL.

Similarly, you can explore so many other options by seeing its manual page –

man curl


OK now if you find any difficulty while using the curl command in Linux then write us in the comments below.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Exit mobile version