The curl command-line utility is an indispensable tool in Linux environments for transferring data using network protocols such as HTTP, HTTPS, FTP, and SCP. It is routinely used to download configuration scripts, test REST APIs, verify SSL certificates, and fetch software repositories. However, minimal Linux installations, container base images (such as Ubuntu, Debian, or Alpine Docker images), and hardened server environments often exclude curl by default, resulting in the error: bash: curl: command not found.
Why Is curl Missing from Linux Systems?
The error indicates that the current terminal shell cannot locate an executable binary named curl in any directory specified by your user’s $PATH environment variable. Typical reasons include:
- Minimal OS Installations: Standard cloud images and container images strip out non-essential utilities to reduce attack surface and disk footprint.
- Corrupted or Missing Binary Symlinks: In rare cases,
curlis installed under/usr/local/binor/opt, but the active shell cannot locate the binary path. - Incomplete Package Manager Initialisation: Package repositories have not yet been indexed on newly provisioned servers, blocking command execution.
Method 1: Install curl on Ubuntu and Debian Distributions
On Debian-derived distributions, including Ubuntu, Linux Mint, and Kali Linux, use the apt package manager to update repository indexes and install the utility.
- Open your terminal or connect via SSH.
- Synchronise the local package index with upstream repositories:
sudo apt update - Install the
curlpackage:sudo apt install curl -y - Verify successful installation by checking the installed version and supported protocols:
curl --version
Method 2: Install curl on RHEL, CentOS, AlmaLinux, and Rocky Linux
Enterprise Linux operating systems utilize either dnf or legacy yum package managers.
- On modern distributions (RHEL 8/9, AlmaLinux, Rocky Linux, Fedora), run:
sudo dnf install curl -y - On legacy CentOS 7 servers, run:
sudo yum install curl -y - Confirm that the binary is available in standard system paths:
which curl
Method 3: Install curl on Alpine Linux and Arch Linux
Lightweight containers and rolling distributions use distinct package managers.
- On Alpine Linux (frequently encountered in Docker containers), execute:
apk add --no-cache curl - On Arch Linux and Manjaro systems, execute:
sudo pacman -S curl --noconfirm - Test connectivity by fetching standard HTTP headers from a public domain:
curl -I https://www.google.com
Method 4: Fix PATH Variable Issues
If you have already installed curl from source or custom packages but the shell still reports the command missing, verify your search path.
- Check the contents of your current
PATHvariable:echo $PATH - Search the filesystem to locate where the
curlbinary is stored:find / -name "curl" 2>/dev/null - If
curlresides in/usr/local/binbut that directory is missing from your path, export it in your profile:export PATH=$PATH:/usr/local/bin - Add this export line to the bottom of your
~/.bashrcor~/.zshrcfile to ensure persistence across future terminal sessions.