hash doesn't show me a list of Bash commands











up vote
0
down vote

favorite












I read in the O'reilly Bash book (third edition, 2005) what I understood as that if I'll execute hash I'll see a "hash table" with a list of all possible Bash commands plus all commands common to most environments including Bash that are available in my system.



Yet in WSL-Ubuntu (16.04 - xenial) I executed hash and got just:




hits    command
1 /usr/bin/mesg



Might this be unique to WSL (I don't have a non-WSL Ubuntu machine to test on right now)?



Update



I misunderstood the chapter - the hash table doesn't include all Bash commands but seemingly all recently used non-bash commands (with the path to the files containing their data);



it's just that the authors gave a list containing some very common commands which I mistakenly confused as "builtin" from a quick look on the list, although they are standalone utilities (and here's the list from the book - page 72):



cat
stat
less
man
apropos
more
ln
ls
ps
vi


Of course, these are not Bash builtin commands like cd, echo, set, shopt, source, bash, if, case, for, while, kill, trap, exit, etc, but standalone utilities very common in Bash based environments.



By now I've internalized the difference deep enough and humbly believe I won't confuse in this embarrasing way again. This is an important lesson for me; I never really dived deep enough on the differences between what very common program is a Bash builtin or a "very common" utility in Bash-based environments that might be grasped as a "builtin" but my stance is - "no more!".










share|improve this question




















  • 1




    By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
    – dessert
    Nov 26 at 22:25















up vote
0
down vote

favorite












I read in the O'reilly Bash book (third edition, 2005) what I understood as that if I'll execute hash I'll see a "hash table" with a list of all possible Bash commands plus all commands common to most environments including Bash that are available in my system.



Yet in WSL-Ubuntu (16.04 - xenial) I executed hash and got just:




hits    command
1 /usr/bin/mesg



Might this be unique to WSL (I don't have a non-WSL Ubuntu machine to test on right now)?



Update



I misunderstood the chapter - the hash table doesn't include all Bash commands but seemingly all recently used non-bash commands (with the path to the files containing their data);



it's just that the authors gave a list containing some very common commands which I mistakenly confused as "builtin" from a quick look on the list, although they are standalone utilities (and here's the list from the book - page 72):



cat
stat
less
man
apropos
more
ln
ls
ps
vi


Of course, these are not Bash builtin commands like cd, echo, set, shopt, source, bash, if, case, for, while, kill, trap, exit, etc, but standalone utilities very common in Bash based environments.



By now I've internalized the difference deep enough and humbly believe I won't confuse in this embarrasing way again. This is an important lesson for me; I never really dived deep enough on the differences between what very common program is a Bash builtin or a "very common" utility in Bash-based environments that might be grasped as a "builtin" but my stance is - "no more!".










share|improve this question




















  • 1




    By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
    – dessert
    Nov 26 at 22:25













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I read in the O'reilly Bash book (third edition, 2005) what I understood as that if I'll execute hash I'll see a "hash table" with a list of all possible Bash commands plus all commands common to most environments including Bash that are available in my system.



Yet in WSL-Ubuntu (16.04 - xenial) I executed hash and got just:




hits    command
1 /usr/bin/mesg



Might this be unique to WSL (I don't have a non-WSL Ubuntu machine to test on right now)?



Update



I misunderstood the chapter - the hash table doesn't include all Bash commands but seemingly all recently used non-bash commands (with the path to the files containing their data);



it's just that the authors gave a list containing some very common commands which I mistakenly confused as "builtin" from a quick look on the list, although they are standalone utilities (and here's the list from the book - page 72):



cat
stat
less
man
apropos
more
ln
ls
ps
vi


Of course, these are not Bash builtin commands like cd, echo, set, shopt, source, bash, if, case, for, while, kill, trap, exit, etc, but standalone utilities very common in Bash based environments.



By now I've internalized the difference deep enough and humbly believe I won't confuse in this embarrasing way again. This is an important lesson for me; I never really dived deep enough on the differences between what very common program is a Bash builtin or a "very common" utility in Bash-based environments that might be grasped as a "builtin" but my stance is - "no more!".










share|improve this question















I read in the O'reilly Bash book (third edition, 2005) what I understood as that if I'll execute hash I'll see a "hash table" with a list of all possible Bash commands plus all commands common to most environments including Bash that are available in my system.



Yet in WSL-Ubuntu (16.04 - xenial) I executed hash and got just:




hits    command
1 /usr/bin/mesg



Might this be unique to WSL (I don't have a non-WSL Ubuntu machine to test on right now)?



Update



I misunderstood the chapter - the hash table doesn't include all Bash commands but seemingly all recently used non-bash commands (with the path to the files containing their data);



it's just that the authors gave a list containing some very common commands which I mistakenly confused as "builtin" from a quick look on the list, although they are standalone utilities (and here's the list from the book - page 72):



cat
stat
less
man
apropos
more
ln
ls
ps
vi


Of course, these are not Bash builtin commands like cd, echo, set, shopt, source, bash, if, case, for, while, kill, trap, exit, etc, but standalone utilities very common in Bash based environments.



By now I've internalized the difference deep enough and humbly believe I won't confuse in this embarrasing way again. This is an important lesson for me; I never really dived deep enough on the differences between what very common program is a Bash builtin or a "very common" utility in Bash-based environments that might be grasped as a "builtin" but my stance is - "no more!".







bash windows-subsystem-for-linux hash






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 at 4:25

























asked Nov 26 at 17:53









JohnDoea

12292158




12292158








  • 1




    By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
    – dessert
    Nov 26 at 22:25














  • 1




    By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
    – dessert
    Nov 26 at 22:25








1




1




By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
– dessert
Nov 26 at 22:25




By the way, if you at any time wonder about a particular command being a bash keyword, a builtin, an external program or whatnot, just run type -a COMMAND.
– dessert
Nov 26 at 22:25










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










As help hash shows, the hash function is used to determine and remember the full pathnames of programs:





hash: hash [-lr] [-p pathname] [-dt] [name ...]
Remember or display program locations.

Determine and remember the full pathname of each command NAME. If
no arguments are given, information about remembered commands is displayed.

Options:
-d forget the remembered location of each NAME
-l display in a format that may be reused as input
-p pathname use PATHNAME as the full pathname of NAME
-r forget all remembered locations
-t print the remembered location of each NAME, preceding
each location with the corresponding NAME if multiple
NAMEs are given
Arguments:
NAME Each NAME is searched for in $PATH and added to the list
of remembered commands.

Exit Status:
Returns success unless NAME is not found or an invalid option is given.


In your case it returns /usr/bin/mesg because obviously mesg has been called before and hash now remembers its path.



To get help on bash builtins, functions etc. there’s the help function. Call it without an argument to get a list of shell commands defined internally. To get a list of bash builtins you can use compgen -b.






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%2f1096249%2fhash-doesnt-show-me-a-list-of-bash-commands%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    As help hash shows, the hash function is used to determine and remember the full pathnames of programs:





    hash: hash [-lr] [-p pathname] [-dt] [name ...]
    Remember or display program locations.

    Determine and remember the full pathname of each command NAME. If
    no arguments are given, information about remembered commands is displayed.

    Options:
    -d forget the remembered location of each NAME
    -l display in a format that may be reused as input
    -p pathname use PATHNAME as the full pathname of NAME
    -r forget all remembered locations
    -t print the remembered location of each NAME, preceding
    each location with the corresponding NAME if multiple
    NAMEs are given
    Arguments:
    NAME Each NAME is searched for in $PATH and added to the list
    of remembered commands.

    Exit Status:
    Returns success unless NAME is not found or an invalid option is given.


    In your case it returns /usr/bin/mesg because obviously mesg has been called before and hash now remembers its path.



    To get help on bash builtins, functions etc. there’s the help function. Call it without an argument to get a list of shell commands defined internally. To get a list of bash builtins you can use compgen -b.






    share|improve this answer



























      up vote
      4
      down vote



      accepted










      As help hash shows, the hash function is used to determine and remember the full pathnames of programs:





      hash: hash [-lr] [-p pathname] [-dt] [name ...]
      Remember or display program locations.

      Determine and remember the full pathname of each command NAME. If
      no arguments are given, information about remembered commands is displayed.

      Options:
      -d forget the remembered location of each NAME
      -l display in a format that may be reused as input
      -p pathname use PATHNAME as the full pathname of NAME
      -r forget all remembered locations
      -t print the remembered location of each NAME, preceding
      each location with the corresponding NAME if multiple
      NAMEs are given
      Arguments:
      NAME Each NAME is searched for in $PATH and added to the list
      of remembered commands.

      Exit Status:
      Returns success unless NAME is not found or an invalid option is given.


      In your case it returns /usr/bin/mesg because obviously mesg has been called before and hash now remembers its path.



      To get help on bash builtins, functions etc. there’s the help function. Call it without an argument to get a list of shell commands defined internally. To get a list of bash builtins you can use compgen -b.






      share|improve this answer

























        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        As help hash shows, the hash function is used to determine and remember the full pathnames of programs:





        hash: hash [-lr] [-p pathname] [-dt] [name ...]
        Remember or display program locations.

        Determine and remember the full pathname of each command NAME. If
        no arguments are given, information about remembered commands is displayed.

        Options:
        -d forget the remembered location of each NAME
        -l display in a format that may be reused as input
        -p pathname use PATHNAME as the full pathname of NAME
        -r forget all remembered locations
        -t print the remembered location of each NAME, preceding
        each location with the corresponding NAME if multiple
        NAMEs are given
        Arguments:
        NAME Each NAME is searched for in $PATH and added to the list
        of remembered commands.

        Exit Status:
        Returns success unless NAME is not found or an invalid option is given.


        In your case it returns /usr/bin/mesg because obviously mesg has been called before and hash now remembers its path.



        To get help on bash builtins, functions etc. there’s the help function. Call it without an argument to get a list of shell commands defined internally. To get a list of bash builtins you can use compgen -b.






        share|improve this answer














        As help hash shows, the hash function is used to determine and remember the full pathnames of programs:





        hash: hash [-lr] [-p pathname] [-dt] [name ...]
        Remember or display program locations.

        Determine and remember the full pathname of each command NAME. If
        no arguments are given, information about remembered commands is displayed.

        Options:
        -d forget the remembered location of each NAME
        -l display in a format that may be reused as input
        -p pathname use PATHNAME as the full pathname of NAME
        -r forget all remembered locations
        -t print the remembered location of each NAME, preceding
        each location with the corresponding NAME if multiple
        NAMEs are given
        Arguments:
        NAME Each NAME is searched for in $PATH and added to the list
        of remembered commands.

        Exit Status:
        Returns success unless NAME is not found or an invalid option is given.


        In your case it returns /usr/bin/mesg because obviously mesg has been called before and hash now remembers its path.



        To get help on bash builtins, functions etc. there’s the help function. Call it without an argument to get a list of shell commands defined internally. To get a list of bash builtins you can use compgen -b.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 26 at 19:36

























        answered Nov 26 at 19:07









        dessert

        21.5k55896




        21.5k55896






























            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%2f1096249%2fhash-doesnt-show-me-a-list-of-bash-commands%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

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?