From Wikipedia, the free encyclopedia
  (Redirected from Chdir)
Jump to: navigation, search

In computing, the working directory of a process is a directory of a hierarchical file system, if any,[1] dynamically associated with each process. It is sometimes called the current working directory or CWD, e.g. the BSD getcwd(3) function. When the process refers to a file using a simple file name or relative path (as opposed to a file designated by a full path from a root directory), the reference is interpreted relative to the current working directory of the process. So for example a process with working directory /rabbit-shoes that asks to create the file foo.txt will end up creating the file /rabbit-shoes/foo.txt.

In operating systems[edit]

In most computer file systems, every directory has an entry (usually named ".") which points to the directory itself.

In most DOS and UNIX command shells, as well as in the Microsoft Windows command line interpreters cmd.exe and Windows PowerShell, the working directory can be changed by using the cd or chdir commands. In Unix shells, the pwd command outputs a full pathname of the current working directory; the equivalent command in DOS and Windows is cd without arguments (whereas in Unix, cd used without arguments takes the user back to his/her home directory). The environment variable PWD (in Unix/Linux shells) or CD (in DOS/Windows shells) is also set for use in scripts, so that one need not start an external program. Microsoft Windows file shortcuts have the ability to store the working directory.

In programming languages[edit]

Most programming languages provide an interface to the file system functions of the operating system, including the ability to set (change) the working directory of the program.

In the C language, the POSIX function chdir() effects the system call which changes the working directory.[2] Its argument is a text string with a path to the new directory, either absolute or relative to the old one. Where available, it can be called by a process to set its working directory.

There is the same function in other languages. In Visual Basic it is usually spelled CHDIR().

Unlike the Windows API or POSIX C function, neither the Java programming language nor the Java Virtual Machine supports chdir() directly;[clarification needed] a change request remained open for over a decade while the team responsible for Java considered the alternatives, though by 2008 the request was denied after only limited support was introduced (affecting first java.lang.Runtime and later, java.lang.ProcessBuilder ).[3]

See also[edit]


  1. ^ There are operating systems that support a hierarchical file system but have no concept of "working directory"; for example Texas Instruments' DX10, used for the TI-990 series.
  2. ^ The Open Group Base Specifications Issue 6 and IEEE Std 1003.1, 2004 Edition
  3. ^ "Java - Bug : 4045688". Bug Database. Sun Microsystems. 1997-04-17. Retrieved 2011-02-20. 

External links[edit]


None of the audio/visual content is hosted on this site. All media is embedded from other sites such as GoogleVideo, Wikipedia, YouTube etc. Therefore, this site has no control over the copyright issues of the streaming media.

All issues concerning copyright violations should be aimed at the sites hosting the material. This site does not host any of the streaming media and the owner has not uploaded any of the material to the video hosting servers. Anyone can find the same content on Google Video or YouTube by themselves.

The owner of this site cannot know which documentaries are in public domain, which has been uploaded to e.g. YouTube by the owner and which has been uploaded without permission. The copyright owner must contact the source if he wants his material off the Internet completely.

Powered by YouTube
Wikipedia content is licensed under the GFDL and (CC) license