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
Cd (command)
(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!
== Use == Use of the command varies by context, but there are widespread similarities among variants. The examples below, mostly apply to Unix and Unix-like shells, PowerShell and Command Prompt. To separate the directory names of a path, a program imposes command-line syntax such as a delimiting text between names {{endash}} which varies by program. In particular, Unix and Unix-like shells use a forward slash {{code|/}}, Command Prompt uses backslash {{code|\}} and PowerShell supports either. For simplicity, paths are shown with forward slashes here. Commonly, a dot is short-hand notation for the working directory and two dots is short-hand for its parent. For example, given working directory {{code|/user/bin/tmp}}, {{code|.}} refers to it and {{code|..}} refers to {{code|/user/bin}}. The parent notation is often used to form a relative path that specifies a path that is both up and down the hierarchy. For example: starting with {{code|/usr/bin/tmp}}, {{code|cd ../../local}} specifies path {{code|/usr/local}}. === Common === Features that are commonly found for any change directory command: * {{code|cd path/to/dir}} For a relative path (no leading slash), the path is appended to the working directory path; moving the context deeper into the directory tree hierarchy; for example, if the working directory is {{code|/usr}}, then {{code|cd bin}} changes the working directory to {{code|/usr/bin}} * {{code|cd /path/to/dir}} For an absolute path (leading slash), the working directory is replaced with the specified path; for example, {{code|cd /bin}} sets the working directory to {{code|/bin}} * {{code|cd ..}} Moves the directory tree context up one directory; for example, starting at {{code|/usr/bin/tmp}}, {{code|cd ..}} changes the working directory to {{code|/usr/bin}} * {{code|cd .}} Does not change the working directory but is useful to recover after a directory is recreated by another process * {{code|cd}} With no arguments, the command changes the working directory to the user's home directory; exception: Command Prompt reports the working directory path === Unix shells === Unix-based shells and PowerShell generally share these features: * {{code|cd ~}} Changes the working directory to user's home directory * <code>cd ~''username''</code> Changes the working directory to the specified user's home directory * {{code|cd -}} Changes the working directory to the previous directory; for example, starting at {{code|/usr/bin/tmp}}, then {{code|cd /etc}}, and then {{code|cd -}} returns to {{code|/usr/bin/tmp}}; this supports toggling between two directories without [[pushd and popd]] === Legacy Microsoft shells === DOS maintains separate working directories for each [[Drive letter assignment|lettered drive]], and also has the concept of a current working drive. The {{code|cd}} command can be used to change the working directory of the working drive or another lettered drive. Typing the drive letter as a command on its own changes the working drive, e.g. {{code|C:}}; alternatively, {{code|cd}} with the {{code|/d}} switch may be used to change the working drive and that drive's working directory in one step. Modern versions of Windows simulate this behaviour for backwards compatibility under [[CMD.EXE]].<ref>{{Cite web|url=https://devblogs.microsoft.com/oldnewthing/2010/10/11|title=October 11, 2010|website=The Old New Thing}}</ref>
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)