The curlicue command is quite useful and flexible. The intent of the tool is to transfer data, without user interaction, to or from a server, using one of the many supported protocols. It is that list of protocols that helps curl manage to exist then flexible, equally the command supports:

  • DICT
  • FILE
  • FTP
  • FTPS
  • GOPHER
  • HTTP
  • HTTPS
  • IMAP
  • IMAPS
  • LDAP
  • LDAPS
  • POP3
  • POP3S
  • RTMP
  • RTSP
  • SCP
  • SMB
  • SMBS
  • SMTP
  • SMTPS
  • TELNET
  • TFTP

That'southward a salubrious list of possibilities. It also means curl can transfer merely about any type of data. Curl can even display the source code of a URL. All of this without requiring user interaction (a crucial feature for scripting).

I want to show you lot how to brand employ of this control (one you'll ofttimes find in Linux howtos and scripts). I'll exist demonstrating on Simple Os, but the command works on nearly every available Linux distribution. Curl is also available on macOS and Windows.

Come across: 20 quick tips to make Linux networking easier (free PDF) (TechRepublic)

Installing roll

Your Linux distribution should take curl installed past default. If not, the installation is quite uncomplicated. On a Debian derivative, the installation command would exist:

sudo apt install roll

You can check the installation by issuing the control coil –version. You should see the version number of the installed application (on my Elementary OS auto, it's 7.47.0).

Using curl

Allow'southward first see how gyre can be used at its simplest. Say you want to view the source of a web site. We'll apply the curl site as an case. Issue the command:

curl https://ringlet.haxx.se | less

Y'all tin at present scroll through the HTML for that site (Figure A).

Figure A

This is a keen way to figure out how a site has been created or even troubleshooting your own sites.

Of course, that example is quite limited. Let'southward use curl to pull downwards a file from a site. Allow's stick with the same example. Say you want to download the HTML for the curl site to view after. For this, nosotros'll use the -o switch similar and then:

coil https://curl.haxx.se -o curl.html

The above command would download the HTML code from the curl site and save information technology as curl.html. Of course, curl isn't but capable of downloading source HTML. Say y'all accept a file you want to download from a site. Curl tin handle this like so:

curl http://SERVER_ADDRESS/FILENAME -o FILENAME

Where SERVER_ADDRESS is the URL of the server and FILENAME is the name of the file to be downloaded. Say for case, y'all want to download the latest release of Ubuntu Server. That tin exist done similar so:

curlicue http://releases.ubuntu.com/18.04/ubuntu-eighteen.04-live-server-amd64.iso -o ubuntu-server-18.04.iso

If that file is password protected, whorl tin can handle that like so:

curl -u USERNAME:PASSWORD http://SERVER_ADDRESS -o FILENAME

Where:

  • USERNAME is the username on the server.
  • Password is the countersign for the user on the server.
  • FILENAME is the file to be downloaded.
  • SERVER_ADDRESS is the directly link to the file.

You lot can as well utilise curl with an FTP server. Say you demand to download a file from an FTP server that happens to be countersign protected. The command for this would be:

curl ftp://SERVER_ADDRESS/FILENAME -user USERNAME:Password -o FILENAME

Where:

  • SERVER_ADDRESS is the address of the FTP server.
  • FILENAME is the proper name of the file to be downloaded.
  • USERNAME is the username on the FTP server.
  • Password is the password for the user on the FTP server.

To upload a file to an FTP server, the control would be:

curl -T FILENAME SERVER_ADDRESS -user USERNAME:Password

Again where:

  • SERVER_ADDRESS is the address of the FTP server.
  • FILENAME is the name of the file to exist downloaded.
  • USERNAME is the username on the FTP server.
  • Password is the countersign for the user on the FTP server.

At some point, the curl developers removed SFTP support from the libcurl. If you lot need to download a file, via SSH, yous'll need to apply the sftp command.

Why use scroll

One of the biggest benefits of roll is that information technology tin be used without interaction. Because of that, it's perfectly suited for scripting. You'll run into many instances of Linux installer scripts that brand apply of curl. Every bit an installer script runs, you might well see curl do its matter past downloading necessary dependencies. So if yous're writing a Linux fustigate (or installer) script, curl will most certainly be your friend. For more than data on curl (and there's a lot of information technology), consequence the command human whorl and read through the manual page.

Learn more about Linux in TechRepublic Academy!

As well see:

  • How to apply the Linux watch command for easier output tracking (TechRepublic)
  • How to use the Linux screen control to proceed your remote processes running (TechRepublic)
  • How to gear up an SFTP server on Linux (TechRepublic)
  • How to monitor a Linux log file in real fourth dimension (TechRepublic)
  • ICANN makes terminal minute WHOIS changes to address GDPR requirements (ZDNet)