Are you seeing “curl: command not found” in the terminal and looking for information on this error message?
curl is a command-line tool used to transfer data to or from a server. It supports a wide range of protocols, including HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, and FILE. Curl is powered by Libcurl and is preferred for automation due to its design to work without user interaction. Curl is often used in conjunction with other programs, responsible for sending a JSON file to a server, submitting a web form, user authentication, proxy support, saving the server response to disk, and more.
In this short article, we will show you a few possible solutions to fix “curl: command not found” error message in Linux.
Most of the time, “curl: command not found” error message means
curl program is not currently installed on your system. Unlike
curl is not part of the default packages that comes with most Linux distributions.
Install curl on Debian and Ubuntu
In order to have
curl installed on your Debian-based system, run the following command:
sudo apt install curl -y
After the installation has completed, you can verify its status by running
Install curl on Alpine Linux
On Alpine Linux, simply enter a terminal and run
apk add curl
In order to install
curl to an Alpine Docker image, you would have to use one of the following command:
For Alpine Linux version 3.3+:
RUN apk --no-cache add curl
For older Alpine Linux versions:
RUN apk add --update curl && \ rm -rf /var/cache/apk/*
Check your PATH environment variable
If you encounter “curl: command not found” error message when trying to run a bash script or an external program, it is very likely that you’ve messed up your
PATH environment variable.
Most operating systems look for executables and binaries in a specific set of places. The list of all those places is stored in an environment variable, often named
curl executable file would be placed in
/usr/bin. But if the latter condition is not satisfied, then “curl: command not found” pops up.
First, you have to find where
curl is located. Since
curl cannot be found by the operating system, we cannot use
which curl to locate it. Instead, try running it using explicit path :
curl: try 'curl --help' or 'curl --manual' for more information means that
curl was put into the right place.
For a temporary fix, you can try setting an alias to the actual path to
curl every time the bash shell starts:
echo "alias curl='/usr/bin/curl'" >> ~/.bashrc; . ~/.bashrc
For a permanent fix, add
/usr/bin back to the
PATH environment variable by running the command below.
We hope that the information above is useful and helped you successfully fix the “curl: command not found” error.
If you have any questions, then please feel free to ask in the comments below.