The command which cd prints nothing. Same for whatis cd and whereis cd. How can I find out if cd is an alias, function, or bash built-in? I'm using Ubuntu 12.04.
- 61,858
- 405
3 Answers
In bash, which is an external utility. It only finds external commands: it does not know about aliases, builtins or functions. The same goes for whatis and whereis.
Forget which and use type instead.
$ type cd
cd is a shell builtin
Builtins don't have a man page of their own (unless they also exist as an external utility, but then you get the documentation of the external utility, which may support different options). They are documented in the bash manual.
See also How to use which on an aliased command? and My which command may be wrong (sometimes)?
- 61,858
man bash will tell you that. Move to the end and then search for BASH BUILTIN COMMANDS. You can read on from there.
- 13,475
To list all bash aliases:
alias
To list all defined function names:
typeset -F
To see the list of bash builtins, check the bash manpage.
You can probably hack together a single script to grep through the output of each command above.
- 9,286