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!".
bash windows-subsystem-for-linux hash
add a comment |
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!".
bash windows-subsystem-for-linux hash
1
By the way, if you at any time wonder about a particular command being abash
keyword, a builtin, an external program or whatnot, just runtype -a COMMAND
.
– dessert
Nov 26 at 22:25
add a comment |
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!".
bash windows-subsystem-for-linux hash
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
bash windows-subsystem-for-linux hash
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 abash
keyword, a builtin, an external program or whatnot, just runtype -a COMMAND
.
– dessert
Nov 26 at 22:25
add a comment |
1
By the way, if you at any time wonder about a particular command being abash
keyword, a builtin, an external program or whatnot, just runtype -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
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
add a comment |
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
.
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
.
edited Nov 26 at 19:36
answered Nov 26 at 19:07
dessert
21.5k55896
21.5k55896
add a comment |
add a comment |
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.
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%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
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
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 runtype -a COMMAND
.– dessert
Nov 26 at 22:25