"cmake –version" points to /usr/bin/cmake while "which cmake" points to /usr/local/bin


I am trying to upgrade cmake on my linux computer. Here is the command I used.

Remove the old cmake:

sudo apt purge --auto-remove cmake

Download and extracted cmake-3.13.3.tar.gz from https://cmake.org/download/

Then in the extracted cmake folder:

sudo make install 

when I did cmake --version it returns

bash: /usr/bin/cmake: No such file or directory

which indicates that no cmake executable exists in /usr/bin. However when I run which cmake it returns


And that does exist.

How do I have the command cmake point to /usr/local/bin/cmake?

My $PATH shows


Edit: different from the other question since I know exactly where the cmake executable is just that --version and which have different effect.


In bash you can use hash -r so that it forgets all remembered locations of previously executed commands.

Answered By – bbu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published