Difference between cd and chdir function

What is the difference between cd shell cd and Perl chdir function? Please explain with an example?

+7
source share
2 answers

The cd changes the current directory of the shell process; the Perl chdir function changes the current directory of the Perl process. They are exactly the same, just written differently.

+12
source

In fact, they both do the same thing, but chdir is a POSIX system call, and cd is a normal function used in a program, which in this case is a shell.

In practice, chdir is called by cd to make changes to the directory, since the program does not have kernel privileges to do this on its own.

0
source

All Articles