Table of Contents
Although cURL is known as an HTTP client, it actually supports FTP, LDAP, SMTP, etc. supports. It is used as a client for many protocols. For example, curl is used to transfer data between two servers using these protocols.
You can sometimes see CURL in a script or sometimes in an application's installation guide. The most used feature of cURL is undoubtedly checking if a URL is accessible. So you never had access to curl? So did you get the "bash: curl: command not found" error?
Let us help you with the causes of this error.
Possible reasons of “bash: curl: command not found” error
Let's talk about possible causes and solutions for this error.
1. cURL package may not be installed
Pull a website with file use of cURL. If cURL is not installed on the system, you will get the following error:
foc@ubuntu22:~$ curl https://www.golinuxcloud.com/wp-content/uploads/screen-1-e1666772015231.jpg Command 'curl' not found, but can be installed with: sudo snap install curl # version 7.84.0, or sudo apt install curl # version 7.81.0-1ubuntu1.4 See 'snap info curl' for additional versions.
We made this example on Ubuntu. Ubuntu informed us that it is not installed on the system and shared the steps to install it. Let's share the installation steps for Ubuntu and some other distributions.
Install the curl package on Debian-based operating systems (Ubuntu, Pardus, Linux Mint, Kali Linux, etc.):
sudo apt install curl -y
sudo apt-get install curl -y
On Ubuntu, you can also install the curl package from the snap store:
sudo snap install curl
Install on Redhat based operating systems (Fedora, Centos, AlmaLinux, Rocky Linux, etc):
sudo dnf -y curl install
sudo yum -y install curl
Install on Arch Linux:
sudo pacman -S curl
Upload to openSUSE Leap:
sudo install zypper curl
2. PATH environment variable may be incorrect
The PATH variable may have been configured incorrectly or incompletely by the user. In this case, you will encounter this error even if cURL is installed on the system.
The cURL command is called from
/bin/curl on the system. If there is no
/bin in the user PATH variable, many commands, including cURL, will not work.
For example, if your PATH variable is:
foc@ubuntu22:~$ echo $PATH /usr/games:/usr/local/games:/snap/bin
When you try to run it with cURL you will get this error:
foc@ubuntu22:~$ curl https://www.golinuxcloud.com/wp-content/uploads/screen-1-e1666772015231.jpg Command 'curl' is available in the following places * /bin/curl * /usr/bin/curl The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable. curl: command not found
You can see where the cURL package on your system was called with the which command:
foc@ubuntu22:~$ which curl /usr/bin/curl
Let's also add the PATH information to call cURL and similar applications:
foc@ubuntu22:~$ export PATH=$PATH:/bin
You won't be getting this error in your work with cURL anymore.
Although this is a temporary change, you can make it permanent by placing this command in respective user's home directory inside
We tried to provide information about what to do for "bash: curl: command not found" error for cURL. If the problem is fixed, you can check out 15+ curl command examples in Linux [Cheat Sheet] that will help you with what you can do with cURL.
You can also get more local help about curl with the following commands:
foc@ubuntu22:~$ curl --help
foc@ubuntu22:~$ man curl
stackoverflow.com - Linux: Curl installed but -bash: :curl: command not found