Since you tagged the question with bash, I assume that you want to know a bash solution.
The solution which immediately springs to mind is to use type
, for instance
type cd
which should answer: cd is a shell builtin
However, there is a caveat. If someone would have overridden the command, for instance by
alias cd='echo x'
you would now get as answer: cd is aliased to 'echo x'
So, do get a more reliable solution, you would do a
type -a cd
and this would then display
cd is aliased to 'echo x'
cd is a shell builtin
cd is /usr/bin/cd
However, this is still not safe. What if someone would have redefined the type
command, i.e.
alias type='echo y'
To catch this case as well, the final recommended solution would be to use
'type' -a cd
The quotes would tell bash to use the builtin type command.