LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   where is command "cd" located? or is it a command/ system call? (https://www.linuxquestions.org/questions/linux-software-2/where-is-command-cd-located-or-is-it-a-command-system-call-237628/)

feetyouwell 10-01-2004 02:46 PM

where is command "cd" located? or is it a command/ system call?
 
as above

Tinkster 10-01-2004 02:49 PM

Neither ... it's a shell-builtin.

man bash (tcsh, ksh ... )
for details


Cheers,
Tink

vincebs 10-01-2004 03:20 PM

It's a built-in command so it doesn't have its own file. As the previous poster mentioned, it's part of the "bash" command line program. (Bash stands for "Bourne Again Shell").

btmiller 10-01-2004 05:36 PM

Random note: the cd shell builtin uses the chdir system call to accomplish its task. Up until about the sixth edition of Unix (sometime in the mid '70s) the change directory command in the Bourne shell was 'chdir' too. I think cd is easier to type :D.

feetyouwell 10-01-2004 06:10 PM

that makes sense now, i just wrote a little shell myself, everything (well not everything technically) works but cd doesn't not work, i guess i need to write it on my own then.

jlliagre 10-01-2004 08:01 PM

By the way, cd used to be an executable on the very early Unix times (late sixties), but was broken just after the fork system call was added to the system.
Here is an excerpt from http://cm.bell-labs.com/cm/cs/who/dmr/hist.html
Quote:

Although the multiple-process idea slipped in very easily indeed, there were some aftereffects that weren't anticipated. The most memorable of these became evident soon after the new system came up and apparently worked. In the midst of our jubilation, it was discovered that the chdir (change current directory) command had stopped working. There was much reading of code and anxious introspection about how the addition of fork could have broken the chdir call. Finally the truth dawned: in the old system chdir was an ordinary command; it adjusted the current directory of the (unique) process attached to the terminal. Under the new system, the chdir command correctly changed the current directory of the process created to execute it, but this process promptly terminated and had no effect whatsoever on its parent shell! It was necessary to make chdir a special command, executed internally within the shell. It turns out that several command-like functions have the same property, for example login.

Copyright © 2004 Lucent Technologies. All rights reserved.


All times are GMT -5. The time now is 11:49 PM.