Difference between these two commands of the Linux terminal?

0

Hi friends, I'm a bit new to the Linux terminal, I'm using Ubuntu and seeing one of the commands in this specific

cd
.

I'm seeing that you have two ways to enter a directory

asi:

 cd /usr/bin

and so:

cd ./bin

What would be the benefit In an area already of administration

I am sorry if the question is very basic but I do not really understand what is the difference between these two commands which is the PRO and CONTRA of each one.

    
asked by simon 20.06.2017 в 18:18
source

2 answers

3
  

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:

  • Start with / ? - > I jump to the root directory and start looking around.

  • Do not start with / ? - > I start looking in the current directory.

That's why cd ./hola and cd hola are equivalents :

  • cd ./hola

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.

  • cd hola

Start in the current directory - > I'm looking for hola - > I enter it.

    
answered by 21.06.2017 / 23:44
source
1

link

It will help you a lot there shows the difference

    
answered by 20.06.2017 в 18:55