To fix the "command curl not found" error in Ubuntu, you must install the curl package using the APT package manager by running sudo apt update && sudo apt install curl -y in your terminal. This error occurs because curl is a powerful tool for transferring data with URLs, but it is not always pre-installed on every Ubuntu flavor or minimal installation image.
What You'll Need
- A computer running Ubuntu (any recent LTS or interim version).
- Access to a terminal window (Ctrl+Alt+T).
- A user account with sudo (administrative) privileges.
- An active internet connection to download the package from the official Ubuntu repositories.
Step-by-Step
- Open the Terminal: Press
Ctrl+Alt+Ton your keyboard or search for "Terminal" in your application menu. This opens the command-line interface where you will enter the installation commands. - Update the Package Index: Before installing any new software, you must synchronize your local package index with the remote repositories to ensure you download the latest version. Type the following command and press Enter:
sudo apt update
You will be prompted for your password. When typing the password, no characters or asterisks will appear on the screen for security reasons; simply type it and press Enter. - Install the curl Package: Once the update process completes, execute the installation command:
sudo apt install curl
The system will calculate the dependencies required for curl and ask for confirmation. - Confirm Installation: When the terminal asks "Do you want to continue? [Y/n]", type
Yand press Enter. The system will then download the .deb package and install it into the system binaries directory. - Verify the Installation: To ensure that the command is now recognized by the shell, check the version of curl installed by running:
curl --version
If successful, the terminal will display the version number, the protocols supported (such as HTTP, HTTPS, FTP), and the features enabled. If you see this output, the "command not found" error is resolved.
Common Mistakes
One of the most frequent mistakes users make is forgetting to run sudo apt update before attempting the installation. If the local package list is outdated, the system may attempt to download a version of curl that no longer exists on the server, resulting in a "404 Not Found" or "Unable to locate package" error. Always update the index first.
Another common error is neglecting the sudo prefix. Since installing software modifies system directories (like /usr/bin), it requires root-level permissions. Running apt install curl without sudo will result in a "Permission denied" or "Are you root?" error message.
Some users confuse curl with wget. While both are used to download files from the web, they are different tools with different syntax. If a tutorial tells you to use curl and you use wget, the flags (like -O or -L) will not work, leading to syntax errors. Ensure you are using the tool specifically requested by the software you are trying to install.
Tips
If you are automating a script and do not want to manually press "Y" during installation, you can use the -y flag: sudo apt install curl -y. This automatically answers yes to all prompts, which is essential for Dockerfiles or bash scripts.
To keep your system lean, you can check if curl is actually needed or if you can use the built-in wget tool, which is more commonly pre-installed on Ubuntu. However, curl is generally more versatile for interacting with APIs and sending POST requests, making it the industry standard for developers.
If you find yourself frequently installing a set of basic tools on new Ubuntu installations, consider creating a small shell script that bundles curl, git, vim, and build-essential into one command to save time during server setup.
Troubleshooting
If you encounter the error "Unable to locate package curl", it usually means your software sources are restricted or misconfigured. First, check your internet connection by pinging a reliable site: ping -c 4 google.com. If the ping fails, your network is the issue.
If the network is fine but the package is still not found, ensure the "main" and "universe" repositories are enabled. You can do this by running sudo add-apt-repository main and sudo add-apt-repository universe, followed by another sudo apt update. These repositories contain the vast majority of community-maintained and official Ubuntu software.
In rare cases, the APT package manager may be locked because another process (like the Software Updater GUI) is running in the background. If you see an error saying "Could not get lock /var/lib/dpkg/lock-frontend", wait a few minutes for the other update to finish. If it remains stuck, you can restart your computer to clear the lock file safely.
If the installation completes but you still see "command not found", your shell's path may be corrupted. Try running the command using its full path: /usr/bin/curl --version. If this works, you need to add /usr/bin to your PATH environment variable in your .bashrc file.
Frequently Asked Questions
Is curl free to use on Ubuntu?
Yes, curl is open-source software distributed under a permissive license and is available for free through the official Ubuntu repositories.
What is the difference between curl and wget?
Curl is designed to transfer data to or from a server and supports a wider array of protocols and complex HTTP requests (like PUT and DELETE). Wget is primarily designed for downloading files and is better at recursive downloading (mirroring entire websites).
Can I install curl without sudo access?
You cannot install curl to the system-wide directories without sudo. However, you can download the curl source code, compile it manually, and install it into a local directory in your home folder (e.g., ~/bin), then add that directory to your PATH.
Does curl support HTTPS?
Yes, curl supports HTTPS and TLS. On Ubuntu, it typically uses the GnuTLS or OpenSSL libraries to handle secure encrypted connections.
How do I remove curl if I no longer need it?
You can uninstall curl by running sudo apt remove curl. If you also want to remove the configuration files associated with it, use sudo apt purge curl.
Why does curl show a warning about certificates?
This usually happens if the server you are connecting to has an expired or self-signed SSL certificate. While you can bypass this with the -k or --insecure flag, it is not recommended for sensitive data as it disables security checks.