Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Working directory
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==In operating systems== {{further|cd (command)|operating system shell}} In most computer file systems, every directory has an entry (usually named "<kbd>.</kbd>") which points to the directory itself. In most [[DOS]] and [[Unix|UNIX]] [[command-line interface|command shell]]s, as well as in the [[Microsoft Windows]] command line interpreters [[cmd.exe]] and [[Windows PowerShell]], the working directory can be changed by using the <kbd>[[CD (command)|CD]]</kbd> or <kbd>[[CHDIR (command)|CHDIR]]</kbd> [[command (computing)|command]]s. In [[Unix shell]]s, the <kbd>[[pwd]]</kbd> command outputs a full pathname of the working directory; the equivalent command in DOS and Windows is <kbd>CD</kbd> or <kbd>CHDIR</kbd> without [[parameter (computer science)|arguments]] (whereas in Unix, <kbd>cd</kbd> used without arguments takes the user back to their [[home directory]]). The [[environment variable]] <kbd>PWD</kbd> (in Unix/Linux shells), or the [[pseudo-environment variable]]s <kbd>[[CD (pseudo-environment variable)|CD]]</kbd> (in Windows [[COMMAND.COM]] and [[cmd.exe]], but not in OS/2 and DOS), or <kbd>_CWD</kbd>, <kbd>_CWDS</kbd>, <kbd>_CWP</kbd> and <kbd>_CWPS</kbd> (under [[4DOS]], [[4OS2]], [[4NT (shell)|4NT]] etc.)<ref name="4DOS_8.00_HELP"/> can be used in scripts, so that one need not start an external program. [[Microsoft Windows]] [[file shortcut]]s have the ability to store the working directory. COMMAND.COM in [[DR-DOS 7.02]] and higher provides <kbd>ECHOS</kbd>, a variant of the <kbd>[[ECHO (DOS command)|ECHO]]</kbd> command omitting the terminating linefeed.<ref name="Caldera_1998_NEW703"/><ref name="4DOS_8.00_HELP"/> This can be used to create a temporary batchjob storing the working directory in an environment variable like <kbd>CD</kbd> for later use, for example: ECHOS SET CD=> SETCD.BAT CHDIR >> SETCD.BAT CALL SETCD.BAT DEL SETCD.BAT Alternatively, under [[Multiuser DOS]] and [[DR-DOS 7.02]] and higher, various internal and external commands support a parameter <kbd>/B</kbd> (for "Batch").<ref name="CCI_1997_HELP"/> This modifies the output of commands to become suitable for direct command line input (when redirecting it into a batch file) or usage as a parameter for other commands (using it as input for another command). Where <kbd>CHDIR</kbd> would issue a directory path like <code>C:\DOS</code>, a command like <kbd>CHDIR /B</kbd> would issue <code>CHDIR C:\DOS</code> instead, so that <kbd>CHDIR /B > RETDIR.BAT</kbd> would create a temporary batchjob allowing to return to this directory later on. The working directory is also displayed by the <kbd>$P</kbd><ref group="nb" name="NB_PROMPT"/> token of the <code>[[PROMPT (DOS command)|PROMPT]]</code> command <ref name="Caldera_1998_USER"/> To keep the prompt short even inside of deep subdirectory structures, the DR-DOS 7.07 COMMAND.COM supports a <kbd>$W</kbd><ref group="nb" name="NB_PROMPT"/> token to display only the deepest subdirectory level. So, where a default <kbd>PROMPT $P$G</kbd> would result f.e. in <code>C:\DOS></code> or <code>C:\DOS\DRDOS></code>, a <kbd>PROMPT $N:$W$G</kbd> would instead yield <code>C:DOS></code> and <code>C:DRDOS></code>, respectively. A similar facility (using <kbd>$W</kbd> and <kbd>$w</kbd>) was added to [[4DOS]] as well.<ref name="4DOS_8.00_HELP"/> {{anchor|CDS}}Under DOS, the absolute paths of the working directories of all logical volumes are internally stored in an array-like data structure called the Current Directory Structure (CDS), which gets dynamically allocated at boot time to hold the necessary number of slots for all logical drives (or as defined by [[LASTDRIVE (CONFIG.SYS directive)|LASTDRIVE]]).<ref name="Schulman_1994_Undocumented-DOS"/><ref name="Paul_1997_NWDOSTIP"/><ref name="Brown_2000_RBIL"/> This structure imposes a length-limit of 66 characters on the full path of each working directory, and thus implicitly also limits the maximum possible depth of subdirectories.<ref name="Schulman_1994_Undocumented-DOS"/> [[DOS Plus]] and older issues of DR DOS (up to [[DR DOS 6.0]], with [[BDOS]] 6.7 in 1991) had no such limitation<ref name="Paul_1997_NWDOSTIP"/><ref name="Paul_1997_NWDOS7UN"/><ref name="4DOS_8.00_HELP"/> due to their implementation using a [[PCMODE|DOS emulation]] on top of a [[Concurrent DOS]]- (and thus [[CP/M-86]]-)derived kernel, which internally organized subdirectories as ''relative'' links to parent directories instead of as ''absolute'' paths.<ref name="Paul_1997_NWDOSTIP"/><ref name="Paul_1997_NWDOS7UN"/> Since [[PalmDOS]] (with BDOS 7.0) and DR DOS 6.0 (1992 update with BDOS 7.1) and higher switched to use a CDS for [[bug compatibility|maximum compatibility]] with DOS programs as well, they faced the same limitations as present in other DOSes.<ref name="Paul_1997_NWDOSTIP"/><ref name="Paul_1997_NWDOS7UN"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)