How to Install and Use Curl on Ubuntu 24.04
Comprehensive tutorial to install and use curl on Ubuntu 24.04 LTS with practical examples for HTTP requests, file downloads, headers, and API debugging.

5 min read
Comprehensive tutorial to install and use curl on Ubuntu 24.04 LTS with practical examples for HTTP requests, file downloads, headers, and API debugging.
- Prerequisites and Supported Releases
- Step 1: Installing Curl on Ubuntu 24.04
- Step 2: Verifying Curl Installation and Supported Protocols
Troubleshooting network connectivity, automating infrastructure scripts, downloading software binaries, and debugging RESTful APIs require a dependable, scriptable data transfer utility. When you install and use curl on ubuntu 24.04, you deploy the industry-standard data transfer utility powered by libcurl, capable of executing complex web interactions directly from your command-line terminal.
Unlike basic download utilities, curl provides granular control over the entire networking stack. You can manipulate HTTP request methods (GET, POST, PUT, DELETE), inject custom authentication tokens, inspect TLS certificate chains, follow multi-hop redirection chains, and measure exact network timing milestones down to the millisecond.
In this tutorial, you will learn how to verify and install curl on Ubuntu 24.04 LTS, master essential command-line flags, download files with resume capabilities, interact with JSON APIs, handle cookies and sessions, and diagnose network latency issues.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat). The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- An active installation of Ubuntu 24.04 LTS (Desktop or Server).
- A user account with active sudo administrative privileges.
- Access to a command-line terminal and active network connectivity.
Step 1: Installing Curl on Ubuntu 24.04
While many Ubuntu installations include curl by default, minimal server images or container environments may omit it. Ubuntu 24.04 provides the latest stable package in its main repository.
Update your local package database index and install curl using the standard APT package manager.
# Refresh package repository index
sudo apt update
# Install curl package
sudo apt install -y curl
Step 2: Verifying Curl Installation and Supported Protocols
Verify that the curl binary is installed properly and check its version output. The --version flag reveals compiled features—including HTTP/2, HTTP/3, TLS backend (OpenSSL), and supported protocols.
Execute the following command in your terminal:
# Check curl version and feature flags
curl --version
Step 3: Basic HTTP GET Requests and File Downloads
By default, invoking curl with a URL prints the remote resource's raw HTML or text content directly to standard output (stdout).
To save the content to a file, you have two options:
• -o : Saves the downloaded content under a custom file name.
• -O: Saves the file using its remote filename extracted from the URL.
# Print webpage content to terminal stdout
curl https://example.com
# Save download to a custom filename
curl -o local_file.html https://example.com
# Download file saving under its remote filename
curl -O https://releases.ubuntu.com/24.04/SHA256SUMS
Step 4: Following HTTP Redirects and Resuming Downloads
Many modern web services issue 301 Moved Permanently or 302 Found redirects. By default, curl does not follow redirects unless you specify the -L (or --location) flag.
Additionally, if a large download is interrupted, use the -C - flag to resume the transfer from where it stalled rather than restarting from the beginning.
# Follow HTTP redirects automatically
curl -L https://ubuntu.com/download
# Resume an interrupted large file download
curl -L -C - -O https://releases.ubuntu.com/24.04/ubuntu-24.04-desktop-amd64.iso
Step 5: Inspecting HTTP Response Headers and Verbose Debugging
Sysadmins frequently need to inspect HTTP response status codes, caching directives, server banners, and cookies without downloading page bodies.
• -I (or --head): Sends a HEAD request to fetch only headers.
• -i: Prints both response headers and the response body.
• -v (or --verbose): Displays the full TLS handshake, IP resolution, request headers, and response headers.
# Fetch only HTTP response headers
curl -I https://ubuntu.com
# Verbose inspection of full TLS handshake and headers
curl -v https://api.github.com
Step 6: Sending HTTP POST Requests and JSON Payloads
When interacting with modern RESTful APIs, you often need to submit form data or JSON documents using HTTP POST.
Use -X POST to specify the method, -H to define custom HTTP headers (such as Content-Type: application/json), and -d to provide the data payload.
# Send a standard form-encoded POST request
curl -X POST -d "param1=value1&param2=value2" https://httpbin.org/post
# Send a JSON API request with headers
curl -X POST https://httpbin.org/post \
-H "Content-Type: application/json" \
-d '{"username": "admin", "service": "web-node01"}'
Step 7: Working with Authentication and Bearer Tokens
API endpoints and protected web consoles often require credentials. curl supports multiple authentication mechanisms:
• Basic Authentication: Use -u username:password.
• Bearer Token Authentication: Pass the token in the Authorization header.
# HTTP Basic Authentication
curl -u "apiuser:SecretPassword123" https://httpbin.org/basic-auth/apiuser/SecretPassword123
# Bearer Token API Authentication
curl -H "Authorization: Bearer my_secure_jwt_token_here" https://api.example.com/v1/servers
Step 8: Measuring Network Latency and Connection Performance
You can use curl's -w (write-out) option to extract detailed connection timing metrics—including DNS lookup time, TCP connect time, TLS handshake time, and time to first byte (TTFB).
Create a timing format file and benchmark an endpoint.
# Benchmark network connection milestones
curl -s -w "\nDNS Lookup: %{time_namelookup}s\nTCP Connect: %{time_connect}s\nTLS Handshake: %{time_appconnect}s\nTime to First Byte: %{time_starttransfer}s\nTotal Duration: %{time_total}s\n" -o /dev/null https://ubuntu.com
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
curl error: (60) SSL certificate problem: self signed certificate
Resolution: In development environments with self-signed certificates, use the -k (or --insecure) flag to bypass certificate validation. In production, always install the root CA certificate into /usr/local/share/ca-certificates/ and run sudo update-ca-certificates.
curl: (7) Failed to connect to host: Connection refused
Resolution: Verify that the remote service daemon is actively listening on the requested port using ss -tulpn, and ensure host firewalls (UFW) permit inbound traffic on that port.
curl: (3) URL using bad/illegal format or missing URL
Resolution: Ensure your URL includes the protocol scheme (e.g. https://example.com rather than just example.com), and wrap URLs containing query parameters in quotation marks to prevent shell character interpretation.
Security Best Practices and Hardening
Never pass sensitive plain-text passwords directly in CLI command arguments (-u user:pass) on shared multi-user systems, as passwords will appear in process listings (ps aux). Use configuration files (~/.netrc) with restricted permissions (0600) instead.
Avoid routinely using -k (--insecure) in production automation scripts, as disabling certificate validation exposes your traffic to man-in-the-middle attacks.
Always inspect and verify shell installation scripts before piping curl output directly into bash (curl -fsSL https://... | sudo bash).
Keep curl updated via sudo apt update && sudo apt upgrade curl to safeguard against published libcurl CVEs.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- Things to Do After Installing Ubuntu 24.04 LTS — Configure core network utilities, firewalls, and performance settings on Ubuntu.
- Initial Server Setup on Ubuntu 24.04 — Hardening server environments, SSH access, and firewall rules.
- How to Configure Static IP Address on Ubuntu 24.04 — Set up persistent network interfaces with Netplan and systemd-networkd.
Authoritative References and Official Documentation
Frequently Asked Questions
Quick answers to common questions and configurations
-s (silent) flag combined with -S (show errors if it fails): curl -sS -O https://example.com/file.zip.-x flag: curl -x socks5h://127.0.0.1:9050 https://check.torproject.org to route traffic through a local proxy.Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides











Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!