Meaning of . and .. directories in linux [duplicate]

When display hidden file and directory in terminal using ls -la it show two directory i.e. . and .. and when list the content of dot(.) directory it contain all file and directories that is in it's parent directory,are it create clone of that file, if yes then there is duplicate files ?

And while running a script we have use that dot directory if we are in directory where it reside like ./script

but not when we run it from another directory like

/Document/myscript/script

why?

0

1 Answer

  • The . is same as saying "current directory". So ./script means execute script file in current directory.
  • The .. is same as saying "parent directory" (one directory up).

Also, if you are in / directory, there is no difference between:

/Document/myscript/script

and

./Document/myscript/script

So when you use the dot (. or ..), the path you provide is relative to current\parent directory you are in.

If you use full path, then the path is absolute path to the file.

5

You Might Also Like