command not found” on Linux

0
7


If you’re a Linux user and you’ve ever encountered the error message “bash: curl: command not found” or “bash: /usr/bin/curl: No such file or directory” don’t worry – you’re not alone! This error often pops up when you try to use the curl command in the terminal, but the system can’t find it.

In this tutorial, you will learn what this error means, and how to install the curl command across all major Linux distributions to fix it.

Understanding “bash: curl: command not found” Error

Firstly, let’s understand that ‘curl‘ is a command-line tool used to transfer data to or from a server, making it a handy tool for downloading files, making requests to APIs, and more.

However, if your system doesn’t recognize the ‘curl‘ command, you’ll see the error message such as:

bash: curl: command not found
OR
bash: /usr/bin/curl: No such file or directory

The most common reason for this error is that ‘curl‘ is not installed on your Linux system. Unlike some other commands that come pre-installed, ‘curl‘ might need to be installed separately.

Installing curl in Linux

To install curl on Linux, use the following appropriate command for your specific Linux distribution.

sudo apt install curl         [On Debian, Ubuntu and Mint]
sudo yum install curl         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/curl  [On Gentoo Linux]
sudo apk add curl             [On Alpine Linux]
sudo pacman -S curl           [On Arch Linux]
sudo zypper install curl      [On OpenSUSE]    
sudo pkg install curl         [On FreeBSD]

Once curl isntalled, you can verify the version by running the following command on your terminal.

curl --version
Install Curl in Linux
Install Curl in Linux

If ‘curl‘ is installed but still not recognized, it might not be in your system’s PATH. The PATH is a list of directories where the system looks for executable files.

You can check if ‘curl‘ is in the PATH by typing.

echo $PATH

If ‘curl‘ is not in the list, you can add it manually. Find the path where ‘curl‘ is installed by running the following command.

which curl

and add it to the PATH in your shell profile file (like ‘.bashrc‘ or ‘.bash_profile‘).

export PATH=$PATH:/usr/bin/curl

Don’t forget to restart your terminal or run the following command to apply the changes.

source ~/.bashrc
Set Curl Path
Set Curl Path
Conclusion

Encountering the “bash: curl: command not found” error is a common problem for Linux users, but it’s easily solvable by either installing ‘curl‘ or ensuring that it’s in your system’s PATH.

Linux provides flexibility and customization, and understanding how to troubleshoot such issues empowers users to make the most of their systems. So, next time you see this error, fear not – you’ve got the tools to fix it!



Source link