Installing Curl on Ubuntu

If you get an error message saying *curl command not found* when trying to download a file with curl, it means that the curl package is not installed on your Ubuntu machine.

curl is included in the default Ubuntu 20.04 repositories. The installation is pretty straightforward:

sudo apt updatesudo apt install curlCopyCopy

Once the installation is complete, verify it by typing curl in your terminal:

curlCopy

The output will look something like this:

curl: try 'curl --help' or 'curl --manual' for more information
Copy

That’s it! You have successfully installed curl on your Ubuntu machine, and you can start using it.

Using curl

When used without any option, curl prints the source code of the URL specified as an argument to the standard output.

For example, the following command will print the source of the gnu.org homepage in your terminal window:

curl <https://gnu.orgCopy>

To download a file with curl, use either the -o or -O options.

The lowercase -o option allows you to specify the name of the saved file:

curl -o linux.tar.xz <https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xzCopy>

When invoked with uppercase -Ocurl saves the file with its original filename:

curl -O <https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xzCopy>

With curl you can also fetch only the HTTP headers of the specified URL:

curl -I <https://www.gnu.org/Copy>