Path difference between ../ and ./

4

8

Could anyone explain the difference between ../ and ./ please.

../system
./system

My understanding is that ../ is the root directory.

But I don't know what ./means.

shinokada

Posted 2009-10-01T11:03:08.347

Reputation: 1 635

Answers

31

./ means the current directory

../ means the parent of the current directory, not the root directory

/ is the root directory

myfile.text is in the current directory, as is ./myfile.text

../myfile.text is one level above you and /myfile.text lives in your root directory.

Bob Kaufman

Posted 2009-10-01T11:03:08.347

Reputation: 501

3To add more detail for future readers: ~/ is your home directory, and you can combine the operators above: ../../file would be a file two directories below. – Rich Bradshaw – 2010-01-18T11:20:03.990

6

. Current Directoy

.. Parent Directory

./system means, a directory/file called system in the current directory.

vpram86

Posted 2009-10-01T11:03:08.347

Reputation: 1 978

However, there would be little use preceding "system" with a "./" if it is a directory -- it's probably an executable. In UNIX/Linux systems, the current directory is not included in the search path for executables, so to run an executable in the current directory, you would preced it with "./" – aviraldg – 2009-10-01T11:11:10.377

4

The . and .. are relative directories to your current location.

The . is the current directory. eg "this". The .. is the previous directory. eg "this.parent".

Robin Day

Posted 2009-10-01T11:03:08.347

Reputation: 253

3

  • . is the current directory
  • .. is the parent directory of the current directory

... which means:

  • ./system is the subdirectory or file called "system" of the current directory
  • ../system is the subdirectory or file called "system" of the parent directory, which makes it a sibling of the current directory.

Tamas Czinege

Posted 2009-10-01T11:03:08.347

Reputation: 376

However, there would be little use preceding "system" with a "./" if it is a directory -- it's probably an executable. In UNIX/Linux systems, the current directory is not included in the search path for executables, so to run an executable in the current directory, you would preced it with "./" – aviraldg – 2009-10-01T11:10:07.710

Oh yeah it might be a regular file as well. – Tamas Czinege – 2009-10-01T11:11:17.973

1

../ is the directory above this one

./ is the current directory

Preet Sangha

Posted 2009-10-01T11:03:08.347

Reputation: 1 126

1

./ means the current directory.

aviraldg

Posted 2009-10-01T11:03:08.347

Reputation: 2 059