Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Cd (command)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Cd (command)
(section)
Add topic