I do not understand what is the difference between these two commands
Logical that you do not see the difference: there is not .
The cd
command ( c hange d irectory) is limited to changing our current working directory. There's no more.
Simply, if you do cd /root
, you are indicating that you want to access a directory called root
, and that it is located (its parent is) the root directory of the system. p>
If you do cd ./bin
, you are indicating that you want to access a directory named bin
, and that it is located (its parent is) the current working directory .
This last form is equivalent to cd bin
. In the absence of an parent explicit , it is assumed that the parent is the current working directory.
There are 3 special parents:
/
The root directory of the system; is the origin of the directory hierarchy.
.
The current working directory . It's the one we're in right now.
..
The parent directory of the current one.
How to change directory? Well, as it suits you. If you are going to enter the Descargas
directory, located in your $HOME
, and you are already in /home/MIUSUARIO
, it is faster (write and execute) to do
cd Descargas
to indicate the full route:
cd /home/MIUSUARIO/Descargas
However, if you are already in Descargas
and want to go to the root directory, it is much faster
cd /
to put, one by one, all the intermediate steps:
cd ../../..
Technical note
Actually, the /
directory if is special. The other 2; .
and ..
no . These are real directory entries, which are found in all system directories, and which point respectively to themselves and the parent directory.
Thus, every time the system attempts to interpret a directory name, the comparison is simple:
That's why cd ./hola
and cd hola
are equivalents :
Start in the current directory - > I'm looking for a directory called .
- > I enter it (as it points to itself, we stay where we are) - > I'm looking for hola
- > I enter it.
Start in the current directory - > I'm looking for hola
- > I enter it.