I already know what it does: It simply goes one directory or folder backwards.
But what's mysterious for me are those two dot.
cd.. #it has the same function as popd with the difference that it changes the
#current working directory
If someone tell me what is the philosophy of putting those two Dots, i would really appreciate it.
..
in filesystem paths represents a given path's parent path.
Without an explicit path preceding the ..
, the implied path is the current [working] directory, so the ..
therefore refers to the current directory's parent directory.
In short: cd
with an argument of ..
changes to the current directory's parent directory, i.e., the directory one level above in the directory hierarchy.
Shell-specific use of ..
with cd
:
The legacy command processor, cmd.exe
("Command Prompt") - seemingly with the internal cd
command specifically (see Mofi's comments on the question) - considers an .
character to implicitly start the cd
command's argument.
cd
command from the ..
argument with a space character, as usual, isn't necessary; that is, instead of cd ..
you can type cd..
, which is a shortcut that users of cmd.exe
have grown accustomed to over the years.PowerShell allows .
characters to be used in command names, so submitting cd..
does not invoke the cd
command (a built-in alias for the Set-Location
cmdlet) with argument ..
- instead, it looks for a command literally named cd..
To accommodate cmd.exe
users who are accustomed to the cd..
shortcut, PowerShell comes with a parameter-less function literally named cd..
, so that submitting cd..
as a command in PowerShell effectively works the same as in cmd.exe
.
cd..
works, not also specifying additional components; that is, something like cd..\Foo
(which works in cmd.exe
) fails.Get-Command cd.. | Format-List
shows information about this function, which reveals that it simply calls Set-Location ..
, which is PowerShell's equivalent of cmd.exe
's cd ..