What is the difference between locate
and which
in Linux?
Why when I use locate mentor
does it list all the mentor but when I used which mentor
it says "no mentor in…" – what does this mean?
linuxlocatewhich
What is the difference between locate
and which
in Linux?
Why when I use locate mentor
does it list all the mentor but when I used which mentor
it says "no mentor in…" – what does this mean?
Best Answer
What is the difference between
locate
andwhich
?locate
uses a previously built database to locate the file.Source locate(1) - Linux man page
Source updatedb(8) - Linux man page
which
looks for an executable file by searching for it in the directories in thePATH
environmental variable.using the same algorithm as
bash
(1).Source which(1) - Linux man page
locate mentor
lists mentor, butwhich mentor
says "no mentor in..."You have some files named
mentor
which can be found in thelocate
database.You don't have an executable file or script named
mentor
in yourPATH
.