I have 2 versions of curl installed on my system, one with http2 support.

I thought I could use which to point to the binary, but it doesn't seem to work the way I expect.

$ curl --http2 -I https://something.example.com
curl: (1) Unsupported protocol
$ which curl
$ /usr/local/bin/curl --http2 -I https://something.example.com
HTTP/2 200  
server: nginx/1.10.0 (Ubuntu)  
date: Thu, 08 Jun 2017 20:55:09 GMT  
content-length: 928  
last-modified: Thu, 08 Jun 2017 19:43:10 GMT  
cache-control: public, max-age=31536000  
accept-ranges: bytes  

which is pointing to my locally built binary /usr/local/bin/curl but the actual command is executing the package binary /usr/bin/curl

I don't have an alias for curl, so can someone please explain to me why this is so? And what command should I run to find the actual path to curl, which I happen to know is /usr/bin/curl

  • 2
    What does type curl say? it may be hashed by the shell Jun 8, 2017 at 21:12
  • it does say curl is hashed (/usr/bin/curl) so does that mean it takes precedence over the PATH? Jun 8, 2017 at 21:15
  • 3
    It's essentially the same issue as this: Pytest is in PATH but not found - you can use hash -r curl to "forget" the hashed location, after which the order in your PATH will be respected Jun 8, 2017 at 21:17

1 Answer 1


If you run:

echo $PATH

You are going to get something similar to:


As you can see, /usr/local/bin has a higher priority, so bash will find your locally installed version of curl first and stop searching any more.

You can change this behavior by editing PATH environment variable, e.g (in .profile):

  • 1
    Thanks for your answer, but which would find it in the same order that my command would. The answer is that it was hashed, skipping the PATH. See the comments. Jun 8, 2017 at 21:23
  • I saw it ;) I leave this answer here, it might be helpful to others :-)
    – Ravexina
    Jun 8, 2017 at 21:42
  • still "which" should follow the same path, what a mess
    – neu-rah
    Aug 16, 2020 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.