Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have gcc installed in /usr/local/bin why linux can't find it

Tags:

linux

gcc

I have gcc installed in /usr/local/bin

[root@iz2 usr]# ls /usr/local/bin | grep gcc
gcc
gcc-ar
gcc-nm
gcc-ranlib
x86_64-pc-linux-gnu-gcc
x86_64-pc-linux-gnu-gcc-7.3.0
x86_64-pc-linux-gnu-gcc-ar
x86_64-pc-linux-gnu-gcc-nm
x86_64-pc-linux-gnu-gcc-ranlib

And there is no gcc in /usr/bin

[root@iz2 usr]# ls /usr/bin | grep gcc
[root@iz2 usr]#

My $PATH like this

[root@iz2 usr]# $PATH
-bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory

when I run commond gcc --version, my linux can't find it, why?

[root@iz2 usr]# gcc --version
-bash: /usr/bin/gcc: No such file or directory

why linux just search /usr/bin directory and ignore the /usr/local/bin directory which has gcc?

like image 686
hongyang Avatar asked Dec 29 '25 09:12

hongyang


1 Answers

It looks like you have not restarted your bash shell since deinstalling /usr/bin/gcc and installing /usr/local/bin/gcc, so it still has an outdated command cache. You can flush the cache using hash -r, or you can just log out and log in again.

like image 92
Florian Weimer Avatar answered Jan 01 '26 02:01

Florian Weimer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!