The “curl: command not found” error in Bash indicates that the cURL is either not installed or inaccessible. To fix this error, install “curl” using the system package manager. For example, run:
sudo apt install -y curl
The curl command is a powerful utility for making HTTP requests, commonly used in scripting and downloading files. Encountering “bash: curl: command not found” indicates that either the curl command-line tool is not installed on your system or the PATH variable is not set for curl. Let’s see the reasons for this error in detail and explore the possible fixes.
Reasons for “curl” Command Not Found Error
Some common reasons for “curl” command not found error are:
- cURL not Installed: If you are unable to use the “curl” command, it could be that your system does not have cURL installed.
- Incorrect Installation Path: The PATH on your system may not contain “curl”.
- Inadequate Permissions: “curl” might not have the authorization it needs to function.
- Binary Not Found: The curl binary might be missing or corrupted.
- Incorrect Spelling: An error in command spelling raises the “command not found” error in Bash.
3 Methods to Solve “bash: curl: command not found” Error
Follow the below methods to solve the curl command not found error in Bash:
1. Install cURL
Most of the time, an incorrect installation of cURL on your system causes the “bash: curl: command not found” error. In this instance, APT in Ubuntu, YUM in RedHat, and Pacman in Arch Linux can install “curl” on your system with all its dependencies. To do that, follow the steps:
- Press CTRL+ALT+T to open the terminal in Ubuntu.
- Run the command to install curl in Ubuntu:
sudo apt install -y curl
- Execute
curl --version
to verify the installation.
Now, the curl command is executed successfully.
2. Set “curl” PATH Variable
A prevalent reason behind the “curl command not found” is cURL is not present in your system PATH environment variables. To set the PATH variable for “curl”, follow the steps below:
- Press CTRL+ALT+T to open the terminal.
- Use which command to check the current path of curl:
which curl
- Open bashrc file using:
nano ~/.bashrc
-
Now, replace <path to curl> in
export PATH=$PATH:<path to curl>
code with the which command’s output and paste it at the end of the file. For example:export PATH=$PATH:/usr/bin/curl
- Press CTRL+S to save, and CTRL+X to exit.
- Then, execute the .bashrc file using:
source ~/.bashrc
- Now you can check running a curl command. For example:
curl --version
After adding the path, the curl command ran without raising any error.
3. Set an Alias to “curl”
To fix the “curl: command not found” error, you can create a temporary solution by setting up an alias for curl. Here’s how you can do it:
echo "alias curl='$(which curl)'" >> ~/.bashrc; . ~/.bashrc
This command appends an alias for the curl command to the ~/.bashrc file and immediately applies the changes in the current terminal session. The alias ensures that the curl
command points to the correct path by using the $(which curl)
syntax, which dynamically retrieves the actual path to the curl executable.
cd /usr/local/bin; ln -s $(which curl) curl
Conclusion
In conclusion, resolving the “bash: curl: command not found” issue involves ensuring the installation of cURL and configuring the system’s PATH appropriately. Applying these solutions allows you to seamlessly access curl commands within the Bash environment and unlock the powerful capabilities of curl in making HTTP requests and downloading files.
People Also Ask
How to install curl in Linux?
To install curl, use a command from the below according to the Linux distribution you’re in:
- Ubuntu/Debian:
sudo apt install curl
- Red Hat/Fedora:
sudo yum install curl
- Arch Linux/Manjaro:
sudo pacman -S curl
- openSUSE:
sudo zypper install curl
- Alpine Linux:
sudo apk add curl
Why is curl command not found?
The “curl command not found” error typically occurs when the ‘curl’ executable is not installed or not in the system’s PATH. To resolve it, install curl using the appropriate package manager for your Linux distribution or ensure that the directory containing ‘curl’ is included in the PATH environment variable.
How to fix curl command not found in RHEL?
To fix the “curl command not found” issue on Red Hat Enterprise Linux (RHEL), use sudo yum install curl
. Once the installation is complete, you should be able to use the ‘curl’ command without encountering the “command not found” error.
How to enable curl in Bash?
To enable curl in Bash:
- Install curl using your system’s package manager. For example, on Ubuntu/Debian:
sudo apt-get install curl
- Verify the installation with:
curl --version
Now you can use commands associated with curl.
How to solve “sudo: curl: command not found”?
To solve “sudo: curl: command not found” error in Linux, follow the steps:
- Run
sudo visudo
command to edit the sudoers file: - Look for the line starting with secure_path and make sure it includes the directory where ‘curl’ is installed. For example:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:<path to curl directory>
Replace <path to curl directory> with the actual path of the ‘curl’ command. You can get it from
which curl
. - Save and close the sudoers file.
Related Articles
- [Fixed] “bash: sudo: command not found” Error
- [Solved] Bash “yarn” Command Not Found Error
- [Solved] Bash “docker” Command Not Found Error
- [Fixed] “bash: ng: command not found” Error
- [Fixed] “bash: java: command not found” Error
- Solved “bash: yum: command not found” [RHEL, Fedora, CentOS]
- [Solved] “bash: vim: command not found” Error
- [Solved] “bash: node: command not found” Error
- [Solved] “bash: code: command not found” Error
- [Fixed!] “systemctl command not found” Error in Linux
<< Go Back to [Solved] “bash: command not found” Error | Bash Error Handling and Debugging | Bash Scripting Tutorial
FUNDAMENTALS A Complete Guide for Beginners