which/whereis differences
up vote
98
down vote
favorite
What's the difference between which
and whereis
?
unix terminal path which
migrated from stackoverflow.com Sep 12 '09 at 22:41
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
98
down vote
favorite
What's the difference between which
and whereis
?
unix terminal path which
migrated from stackoverflow.com Sep 12 '09 at 22:41
This question came from our site for professional and enthusiast programmers.
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
@Wolf here's an example ofwhich
andwhereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…
– Matthew
Oct 28 '16 at 10:09
@mk12 I feel liketype
is superior. It also knows about defined aliases, functions etc
– Blauhirn
Aug 19 at 3:32
add a comment |
up vote
98
down vote
favorite
up vote
98
down vote
favorite
What's the difference between which
and whereis
?
unix terminal path which
What's the difference between which
and whereis
?
unix terminal path which
unix terminal path which
edited Oct 15 '13 at 17:04
Shekhar
4,52232945
4,52232945
asked Sep 12 '09 at 20:12
mk12
1,01241733
1,01241733
migrated from stackoverflow.com Sep 12 '09 at 22:41
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Sep 12 '09 at 22:41
This question came from our site for professional and enthusiast programmers.
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
@Wolf here's an example ofwhich
andwhereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…
– Matthew
Oct 28 '16 at 10:09
@mk12 I feel liketype
is superior. It also knows about defined aliases, functions etc
– Blauhirn
Aug 19 at 3:32
add a comment |
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
@Wolf here's an example ofwhich
andwhereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…
– Matthew
Oct 28 '16 at 10:09
@mk12 I feel liketype
is superior. It also knows about defined aliases, functions etc
– Blauhirn
Aug 19 at 3:32
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
@Wolf here's an example of
which
and whereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…– Matthew
Oct 28 '16 at 10:09
@Wolf here's an example of
which
and whereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…– Matthew
Oct 28 '16 at 10:09
@mk12 I feel like
type
is superior. It also knows about defined aliases, functions etc– Blauhirn
Aug 19 at 3:32
@mk12 I feel like
type
is superior. It also knows about defined aliases, functions etc– Blauhirn
Aug 19 at 3:32
add a comment |
4 Answers
4
active
oldest
votes
up vote
109
down vote
accepted
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs withwhereis
, not the one forwhich
.
– Jordan Reiter
Aug 21 '16 at 22:25
1
@JordanReiter: It can't be!which
shows the actual path. Are you sure the path pointed bywhich
isn't just a symlink to the path pointed bywhereis
? Maybe it is a shell alias. In bash, try runningtype your_cmd_here
.
– Denilson Sá Maia
Aug 22 '16 at 0:01
|
show 2 more comments
up vote
21
down vote
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
add a comment |
up vote
6
down vote
Quoting their man pages :
whereis :
whereis locates source/binary and
manuals sections for specified files.
For instance :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
ie, the "php" executable, and some other stuff (like man pages).
and which :
which returns the pathnames of the
files which would be executed in the
current environment
For instance :
$ which php
/usr/bin/php
ie, only the "php" executable.
add a comment |
up vote
1
down vote
which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.
$ which ls
/bin/ls
$ which ifconfig
$ # No output, because ifconfig only exist in root's PATH.
whereis search for executables, source files, and manual pages using a database built by system automatically.
$ whereis less
less: /bin/less /usr/bin/less /usr/bin/X11/less /usr/share/man/man1/less.1.gz
But it seems that whereis and locate don't use the same database. When I installed a software and then used whereis and locate immediately to search for this software. The result is that whereis could find out some files related to this software while locate couldn't. Do they really use different database? How the database work? --Well, how about refuse to be a pedant? :)
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f40301%2fwhich-whereis-differences%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
109
down vote
accepted
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs withwhereis
, not the one forwhich
.
– Jordan Reiter
Aug 21 '16 at 22:25
1
@JordanReiter: It can't be!which
shows the actual path. Are you sure the path pointed bywhich
isn't just a symlink to the path pointed bywhereis
? Maybe it is a shell alias. In bash, try runningtype your_cmd_here
.
– Denilson Sá Maia
Aug 22 '16 at 0:01
|
show 2 more comments
up vote
109
down vote
accepted
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs withwhereis
, not the one forwhich
.
– Jordan Reiter
Aug 21 '16 at 22:25
1
@JordanReiter: It can't be!which
shows the actual path. Are you sure the path pointed bywhich
isn't just a symlink to the path pointed bywhereis
? Maybe it is a shell alias. In bash, try runningtype your_cmd_here
.
– Denilson Sá Maia
Aug 22 '16 at 0:01
|
show 2 more comments
up vote
109
down vote
accepted
up vote
109
down vote
accepted
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
How about learning about whereis
and which
using whatis
?
$ whatis which
which (1) - shows the full path of (shell) commands
$ whatis whereis
whereis (1) - locate the binary, source, and manual page files for a command
Basically, whereis
searches for "possibly useful" files, while which
only searches for executables.
I rarely use whereis
. On the other hand, which
is very useful, specially in scripts. which
is the answer for the following question: Where does this command come from?
$ which ls
/bin/ls
$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1p.bz2 /usr/share/man/man1/ls.1.bz2
answered Sep 12 '09 at 20:38
Denilson Sá Maia
5,591113138
5,591113138
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs withwhereis
, not the one forwhich
.
– Jordan Reiter
Aug 21 '16 at 22:25
1
@JordanReiter: It can't be!which
shows the actual path. Are you sure the path pointed bywhich
isn't just a symlink to the path pointed bywhereis
? Maybe it is a shell alias. In bash, try runningtype your_cmd_here
.
– Denilson Sá Maia
Aug 22 '16 at 0:01
|
show 2 more comments
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs withwhereis
, not the one forwhich
.
– Jordan Reiter
Aug 21 '16 at 22:25
1
@JordanReiter: It can't be!which
shows the actual path. Are you sure the path pointed bywhich
isn't just a symlink to the path pointed bywhereis
? Maybe it is a shell alias. In bash, try runningtype your_cmd_here
.
– Denilson Sá Maia
Aug 22 '16 at 0:01
28
28
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
didn't know about whatis, thanks.
– mk12
Sep 12 '09 at 20:39
1
1
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
BTW, I'd remove the "osx" tag, as this question applies to all unix variants (including Linux, BSD, Mac OS X, ...)
– Denilson Sá Maia
Sep 12 '09 at 20:44
changed to unix
– mk12
Sep 12 '09 at 23:24
changed to unix
– mk12
Sep 12 '09 at 23:24
1
1
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs with
whereis
, not the one for which
.– Jordan Reiter
Aug 21 '16 at 22:25
There's more to it than that. On my system, whereis and which return different executable paths. I can only get the path to the one that actually runs with
whereis
, not the one for which
.– Jordan Reiter
Aug 21 '16 at 22:25
1
1
@JordanReiter: It can't be!
which
shows the actual path. Are you sure the path pointed by which
isn't just a symlink to the path pointed by whereis
? Maybe it is a shell alias. In bash, try running type your_cmd_here
.– Denilson Sá Maia
Aug 22 '16 at 0:01
@JordanReiter: It can't be!
which
shows the actual path. Are you sure the path pointed by which
isn't just a symlink to the path pointed by whereis
? Maybe it is a shell alias. In bash, try running type your_cmd_here
.– Denilson Sá Maia
Aug 22 '16 at 0:01
|
show 2 more comments
up vote
21
down vote
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
add a comment |
up vote
21
down vote
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
add a comment |
up vote
21
down vote
up vote
21
down vote
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)
whereis
searches the standard *nix locations for a specified command.
which
searches your user-specific PATH (which may include some of the locations whereis searches, and may not include others - it might also include some places that whereis
doesn't search if you'd added to your PATH)
answered Sep 12 '09 at 20:16
Amber
53134
53134
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
add a comment |
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
What is *nix?
– mk12
Sep 12 '09 at 20:19
What is *nix?
– mk12
Sep 12 '09 at 20:19
2
2
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
Unix, Linux etc. (Mac OS X belonging in the etc.)
– Tom
Sep 12 '09 at 20:23
8
8
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Ohhh, haha, I always thought that stack overflow was censoring the U in unix whenever I saw that for some reason..
– mk12
Sep 12 '09 at 22:19
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
Nope. Just a fairly common convention of creative wildcard use to refer to a family of similar operating systems. ;)
– Dav
Sep 12 '09 at 22:28
add a comment |
up vote
6
down vote
Quoting their man pages :
whereis :
whereis locates source/binary and
manuals sections for specified files.
For instance :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
ie, the "php" executable, and some other stuff (like man pages).
and which :
which returns the pathnames of the
files which would be executed in the
current environment
For instance :
$ which php
/usr/bin/php
ie, only the "php" executable.
add a comment |
up vote
6
down vote
Quoting their man pages :
whereis :
whereis locates source/binary and
manuals sections for specified files.
For instance :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
ie, the "php" executable, and some other stuff (like man pages).
and which :
which returns the pathnames of the
files which would be executed in the
current environment
For instance :
$ which php
/usr/bin/php
ie, only the "php" executable.
add a comment |
up vote
6
down vote
up vote
6
down vote
Quoting their man pages :
whereis :
whereis locates source/binary and
manuals sections for specified files.
For instance :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
ie, the "php" executable, and some other stuff (like man pages).
and which :
which returns the pathnames of the
files which would be executed in the
current environment
For instance :
$ which php
/usr/bin/php
ie, only the "php" executable.
Quoting their man pages :
whereis :
whereis locates source/binary and
manuals sections for specified files.
For instance :
$ whereis php
php: /usr/bin/php /usr/share/php /usr/share/man/man1/php.1.gz
ie, the "php" executable, and some other stuff (like man pages).
and which :
which returns the pathnames of the
files which would be executed in the
current environment
For instance :
$ which php
/usr/bin/php
ie, only the "php" executable.
answered Sep 12 '09 at 20:17
Pascal MARTIN
78267
78267
add a comment |
add a comment |
up vote
1
down vote
which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.
$ which ls
/bin/ls
$ which ifconfig
$ # No output, because ifconfig only exist in root's PATH.
whereis search for executables, source files, and manual pages using a database built by system automatically.
$ whereis less
less: /bin/less /usr/bin/less /usr/bin/X11/less /usr/share/man/man1/less.1.gz
But it seems that whereis and locate don't use the same database. When I installed a software and then used whereis and locate immediately to search for this software. The result is that whereis could find out some files related to this software while locate couldn't. Do they really use different database? How the database work? --Well, how about refuse to be a pedant? :)
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
add a comment |
up vote
1
down vote
which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.
$ which ls
/bin/ls
$ which ifconfig
$ # No output, because ifconfig only exist in root's PATH.
whereis search for executables, source files, and manual pages using a database built by system automatically.
$ whereis less
less: /bin/less /usr/bin/less /usr/bin/X11/less /usr/share/man/man1/less.1.gz
But it seems that whereis and locate don't use the same database. When I installed a software and then used whereis and locate immediately to search for this software. The result is that whereis could find out some files related to this software while locate couldn't. Do they really use different database? How the database work? --Well, how about refuse to be a pedant? :)
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
add a comment |
up vote
1
down vote
up vote
1
down vote
which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.
$ which ls
/bin/ls
$ which ifconfig
$ # No output, because ifconfig only exist in root's PATH.
whereis search for executables, source files, and manual pages using a database built by system automatically.
$ whereis less
less: /bin/less /usr/bin/less /usr/bin/X11/less /usr/share/man/man1/less.1.gz
But it seems that whereis and locate don't use the same database. When I installed a software and then used whereis and locate immediately to search for this software. The result is that whereis could find out some files related to this software while locate couldn't. Do they really use different database? How the database work? --Well, how about refuse to be a pedant? :)
which search for executables in the directories specified by the environment variable PATH. And if found out, the full pathname of this executable will be printed.
$ which ls
/bin/ls
$ which ifconfig
$ # No output, because ifconfig only exist in root's PATH.
whereis search for executables, source files, and manual pages using a database built by system automatically.
$ whereis less
less: /bin/less /usr/bin/less /usr/bin/X11/less /usr/share/man/man1/less.1.gz
But it seems that whereis and locate don't use the same database. When I installed a software and then used whereis and locate immediately to search for this software. The result is that whereis could find out some files related to this software while locate couldn't. Do they really use different database? How the database work? --Well, how about refuse to be a pedant? :)
answered Jan 24 '13 at 15:09
user192505
111
111
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
add a comment |
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
did you run updatedb command? locate relies on that as far as I remember
– Oliver M Grech
Feb 2 at 10:37
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f40301%2fwhich-whereis-differences%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I'm sorry but on my 10.5.8 OS X system which and whereis always give the same results. Maybe this is a very OS X specific question, since I agree, a different result is expected. Maybe whereis does not comply to what it should do. At least the two examples (see below) are not working: whereis ls and whereis php always give the same result as which ... Can anybody confirm this? Does Snow Leopard behave the same?
– Wolf
Sep 12 '09 at 23:11
Yeah I know, thats why I asked this question.
– mk12
Sep 12 '09 at 23:25
@Wolf here's an example of
which
andwhereis
giving different output (on macOS Sierra) apple.stackexchange.com/questions/259047/…– Matthew
Oct 28 '16 at 10:09
@mk12 I feel like
type
is superior. It also knows about defined aliases, functions etc– Blauhirn
Aug 19 at 3:32