what is the difference between cd and chdir command. both commands execute the same function. If both have the same function , why do we need two commands ??
Nothing is different. They're just renamed versions of the exact same thing. cd is just shortened. http://technet.microsoft.com/en-us/library/bb490875.aspx
cd
is for lazy people.
On a slightly more serious note, on Windows they're both in fact the exact same thing.
C:\>cd /?
Displays the name of or changes the current directory.
CHDIR [/D] [drive:][path]
CHDIR [..]
CD [/D] [drive:][path]
CD [..]
cd
is the shell command, chdir
is the system call that it uses. They're on different levels of the software stack.
I believe you have to type the full path for CD no matter what, and for CHDIR you can specify subfolders without typing the full path.
Example from instructables.com
In C programming:
In C programs, and other programming languages too, chdir()
is the function used to change the current directory.
For Windows:
cd
and chdir
are both commands in the Windows command line that does the exact same thing, and cd
is really just an alias for chdir
.
For Unix::
cd
is the shell command to change directories in Unix systems, while chdir()
is - as noted above - only available as a function for C programs. chdir
might work on some Unix systems as a shell command too, but it does not work on my Linux machine, though.