1

This question already has an answer here:

I suggested using which to confirm whether a command works only as a shell builtin or alias. cd is an example of a command that works as a shell builtin. It would be much harder to implement the same function as a binary...

So why does my Fedora system have a binary /usr/bin/cd? It doesn't implement the magic necessary to affect the shell (parent process) working directory, to match the behaviour of the cd builtin. My Debian 8 system doesn't have /usr/bin/cd.

$ command -v sudo
/usr/bin/sudo
$ command -v cd
cd
$ which sudo
/usr/bin/sudo
$ which cd
/usr/bin/cd
$ rpm -q --whatprovides /usr/bin/cd
bash-4.3.43-4.fc25.x86_64
$ (. /etc/os-release && echo $PRETTY_NAME)
Fedora 25 (Workstation Edition)
$ pwd
/home/alan
$ cd /home && pwd
/home
$ /usr/bin/cd /home/alan && pwd
/home
$ cd --help
bash: cd: --: invalid option
cd: usage: cd [-L|[-P [-e]] [-@]] [dir]

The full list of binaries provided by the bash package is

$ rpm -q --dump bash|grep /usr/bin|cut -f 1 -d ' '|cut -f 4

alias bash bashbug bashbug-64 bg cd command fc fg getopts hash jobs read sh type ulimit umask unalias wait

marked as duplicate by Stéphane Chazelas bash Mar 27 '17 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Once upon a time, when I was a student, we were assigned a work to write a shell. At some point, I thought it was unneeded to implement a built-in cd command, since there was a cd executable somewhere… Then I understood how wrong I was. Anyway, there was also a cd executable in Solaris, and I still have no idea how it might be useful… – user2233709 Mar 27 '17 at 14:33
  • 1
    See also #820192. – Stephen Kitt Mar 27 '17 at 14:36
  • 1

Browse other questions tagged or ask your own question.