52

What does "/" , "./", "../" represent while giving path?

0

5 Answers 5

62

Root directory, current working directory, and parent directory, respectively.

1
  • 1
    Using folder/file.html is the same as linking to ./folder/file.html. Is there a use-case where one would prefer one or the other?
    – Merc
    Apr 20, 2021 at 17:59
64

The path meanings:

  • / is the root of the current drive;
  • ./ is the current directory;
  • ../ is the parent of the current directory.
1
  • 2
    ../folder go to parent directory, ../../folder go to parent of parent directory and so on.
    – MHSaffari
    May 22, 2021 at 10:58
17

Let's be precise:

"/"is a path which begins with a /, and thus it is an absolute path. Thus, we need to begin in the root of the file system and navigate through the folders given by name, whereas the names are separated by /s (because this is the unix path separator).
Thus, / is the root of the file system with no folders entered after this, and thus, / describes the root of the file system.

./ does not begin with a /, and thus ./ cannot be an absolute file name. Thus, it is a relative file system name. Thus, we need to start with the current working directory and apply the navigation operations which are separated by the path separator again. In this case, the operation is ".", which means: stay in the current folder. (Thus, one has to type ./foo in order to execute foo in the current directory, if . is not in the path-variable). After the "stay in the current folder", nothing further happens, so ./ describe the current working directory.

Given the knowledge that .. means: go to the parent folder, ../ should be easy to deduce and is left as an exercise.

8
  • / is the root folder of the filesystem.
  • ./ usually denotes the current folder that your program or script is in, usually the same one with the file you run.
  • ../ denotes the folder above the current one.
5

the slash / is the directory separator. in every directory there are two directories, namely . (current directory) and .. (parent directory)

if a path starts with a slash, it means it's the root of the filesystem. if you omit the slash in the beginning ./ (relative to current directory) is assumed

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .