whereis returns different path to which











up vote
3
down vote

favorite












I utilize command whereis



$ whereis rm
/bin/rm


when it come to which



$ which rm
/usr/local/opt/coreutils/libexec/gnubin/rm


They are different,



which path I actually applied when issue command "rm readme"










share|improve this question


















  • 3




    type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
    – steeldriver
    5 hours ago










  • What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
    – Terrance
    4 hours ago

















up vote
3
down vote

favorite












I utilize command whereis



$ whereis rm
/bin/rm


when it come to which



$ which rm
/usr/local/opt/coreutils/libexec/gnubin/rm


They are different,



which path I actually applied when issue command "rm readme"










share|improve this question


















  • 3




    type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
    – steeldriver
    5 hours ago










  • What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
    – Terrance
    4 hours ago















up vote
3
down vote

favorite









up vote
3
down vote

favorite











I utilize command whereis



$ whereis rm
/bin/rm


when it come to which



$ which rm
/usr/local/opt/coreutils/libexec/gnubin/rm


They are different,



which path I actually applied when issue command "rm readme"










share|improve this question













I utilize command whereis



$ whereis rm
/bin/rm


when it come to which



$ which rm
/usr/local/opt/coreutils/libexec/gnubin/rm


They are different,



which path I actually applied when issue command "rm readme"







bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 6 hours ago









user10726006

453




453








  • 3




    type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
    – steeldriver
    5 hours ago










  • What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
    – Terrance
    4 hours ago
















  • 3




    type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
    – steeldriver
    5 hours ago










  • What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
    – Terrance
    4 hours ago










3




3




type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
– steeldriver
5 hours ago




type rm is likely to be more reliable than either - since it will show any path that has been cached by the shell
– steeldriver
5 hours ago












What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
– Terrance
4 hours ago






What version of Ubuntu are you running? A default installation of Ubuntu will have the command rm contained only in the /bin folder in the path. Everything I am finding for that which command is that it comes from brew installing the coreutils on a Mac.
– Terrance
4 hours ago












2 Answers
2






active

oldest

votes

















up vote
5
down vote













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.



$  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


Source: https://superuser.com/a/40304/959374






share|improve this answer






























    up vote
    1
    down vote













    According to manual of which:




    which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.




    According to manual of whereis:




    whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.




    So clearly there is a very thin of difference among them. which results include path of executable file while whereis results in binaries and documentation.



    For example, consider java:





    • which results in just one path, i.e. path of java executable file



      /usr/bin/java



    • whereis results in about paths, i.e. path of java binary, source and manual



      java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz







    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      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
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1100315%2fwhereis-returns-different-path-to-which%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      5
      down vote













      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.



      $  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


      Source: https://superuser.com/a/40304/959374






      share|improve this answer



























        up vote
        5
        down vote













        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.



        $  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


        Source: https://superuser.com/a/40304/959374






        share|improve this answer

























          up vote
          5
          down vote










          up vote
          5
          down vote









          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.



          $  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


          Source: https://superuser.com/a/40304/959374






          share|improve this answer














          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.



          $  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


          Source: https://superuser.com/a/40304/959374







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 hours ago

























          answered 5 hours ago









          mature

          1,310420




          1,310420
























              up vote
              1
              down vote













              According to manual of which:




              which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.




              According to manual of whereis:




              whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.




              So clearly there is a very thin of difference among them. which results include path of executable file while whereis results in binaries and documentation.



              For example, consider java:





              • which results in just one path, i.e. path of java executable file



                /usr/bin/java



              • whereis results in about paths, i.e. path of java binary, source and manual



                java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz







              share|improve this answer



























                up vote
                1
                down vote













                According to manual of which:




                which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.




                According to manual of whereis:




                whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.




                So clearly there is a very thin of difference among them. which results include path of executable file while whereis results in binaries and documentation.



                For example, consider java:





                • which results in just one path, i.e. path of java executable file



                  /usr/bin/java



                • whereis results in about paths, i.e. path of java binary, source and manual



                  java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz







                share|improve this answer

























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  According to manual of which:




                  which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.




                  According to manual of whereis:




                  whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.




                  So clearly there is a very thin of difference among them. which results include path of executable file while whereis results in binaries and documentation.



                  For example, consider java:





                  • which results in just one path, i.e. path of java executable file



                    /usr/bin/java



                  • whereis results in about paths, i.e. path of java binary, source and manual



                    java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz







                  share|improve this answer














                  According to manual of which:




                  which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.




                  According to manual of whereis:




                  whereis locates the binary, source and manual files for the specified command names. The supplied names are first stripped of leading pathname components and any (single) trailing extension of the form .ext (for example: .c) Prefixes of s. resulting from use of source code control are also dealt with. whereis then attempts to locate the desired program in the standard Linux places, and in the places specified by $PATH and $MANPATH.




                  So clearly there is a very thin of difference among them. which results include path of executable file while whereis results in binaries and documentation.



                  For example, consider java:





                  • which results in just one path, i.e. path of java executable file



                    /usr/bin/java



                  • whereis results in about paths, i.e. path of java binary, source and manual



                    java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 5 hours ago

























                  answered 5 hours ago









                  Kulfy

                  2,50531034




                  2,50531034






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • 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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1100315%2fwhereis-returns-different-path-to-which%23new-answer', 'question_page');
                      }
                      );

                      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







                      Popular posts from this blog

                      What visual should I use to simply compare current year value vs last year in Power BI desktop

                      How to ignore python UserWarning in pytest?

                      Alexandru Averescu