You follow a tutorial, run a command, and get: curl: command not found. It simply means curl is not installed on your system yet.
Curl is a command-line tool for transferring data to and from remote servers. It supports a wide range of protocols including HTTP, HTTPS, FTP, SFTP, and SCP. Developers use it to test REST APIs, automate file downloads in shell scripts, debug server headers, and interact with web services without opening a browser. It is powered by the libcurl library, which is embedded in thousands of programs across multiple languages.
On a fresh Ubuntu server or minimal desktop installation, curl may not be pre-installed. This guide shows you how to install curl on Ubuntu 18.04 and covers the most common use cases.
<strong>Prerequisite:</strong> You need sudo access.
Curl is included in Ubuntu’s default repositories. Install it with:
bashsudo apt install curl
Verify the installation by running curl with no arguments:
bashcurl
You will see a short help prompt:
curl: try 'curl --help' or 'curl --manual' for more information
That output confirms curl is installed and available on your system.
In its simplest form, curl fetches the content of a URL and prints it to your terminal. This prints the HTML source of the example.com homepage directly to the screen:
bashcurl https://example.com
To download a file and save it with a custom name, use the -o flag:
bashcurl -o linux.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
To save the file using its original filename from the server, use the uppercase -O flag:
bashcurl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
If a download gets interrupted, resume it with the -C - flag instead of starting over from scratch:
bashcurl -C - -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
Fetch HTTP headers only
To inspect a server’s response headers without downloading the full page body, use the -I flag:
bashcurl -I https://www.ubuntu.com/
The output shows the response status code, content type, cache headers, and more. The status code on the first line (such as 200 OK, 301 Moved Permanently, or 404 Not Found) gives you a quick signal of how the server responded, without downloading any page content. This is useful for checking redirects, confirming SSL is active, or verifying caching configuration.
Follow redirects
By default, curl does not follow HTTP redirects. Add the -L flag to tell curl to follow any redirect it receives:
bashcurl -L https://example.com
Download from an FTP server
To download from a password-protected FTP server, pass the credentials with the -u flag:
bashcurl -u FTP_USERNAME:FTP_PASSWORD ftp://ftp.example.com/file.tar.gz
Test a REST API endpoint
Curl is widely used to test APIs directly from the terminal. This example sends a POST request with a JSON body:
bashcurl -X POST https://api.example.com/data \ -H "Content-Type: application/json" \ -d '{"key": "value"}' The -H flag adds a custom header, -X sets the HTTP method, and -d sends the request body.
Curl is now installed on your Ubuntu 18.04 system. For a complete list of available options, run curl --manual in your terminal or visit the official curl documentation. Leave a comment below if you run into any issues.
Nginx is a high-performance web server and reverse proxy trusted by some of the largest…
ufw (Uncomplicated Firewall) sits on top of iptables (or nftables on newer systems) and replaces…
When you share a server with a team or investigate unexpected activity, the first question…
The file command inspects the actual contents of a file and reports its type — regardless of…
chattr sets and removes special file attributes that operate at the filesystem level, separate from standard…
env prints the current environment, sets or removes variables for a single command, and can start…