Whenever you type ls -a into the command prompt, you usually get all of your folders, files, and then you see that the first two entries are . and ..

Just curious, but what is the significance of these two entries?

  • 4
    To not list . and .. you can use ls -A. – Nykakin Apr 24 '13 at 12:01
  • Note that they are not necessarily the first ones, it just so happens that the . character, in most locales, sorts before the characters usually used as the first character of a file name (but there still are plenty of characters that sort before .). – Stéphane Chazelas Jan 2 '16 at 21:48

. is the relative reference for the current directory.
.. is the relative reference for the parent directory.

This is why cd .. makes the parent directory the new working directory.

| improve this answer | |
  • 5
    This also explains the ./ that you have to type when you want to run a executable from the current directory. It's the equivalent to typing /the/full/path/to/the/executable. (had one of these "ahh" moments when I realized that :) ) – alextsc Oct 1 '11 at 19:58
  • 2
    In most cases "." and ".." are also absolute references to the corresponding INODE (or other internal structure element of the used filesystem) of the current or "below" directory. – Nils Oct 1 '11 at 20:53
  • 1
    one exception to this rule is the root dir / where . and .. both point to the current dir. – Sirex Oct 3 '11 at 6:55
  • Sirex's comment is important because it's what allows you to ../../../../../../../../../../../../../../.. for as long as you want and not break anything. – Dason Oct 31 '11 at 5:19

. and .. are hard links to the current and the parent directory (/ is the parent of itself).

With the -a option ls shows all inodes in the current directory, i.e. also the hidden files which filenames begin with ad dot, therefore . and .. are shown.

| improve this answer | |
  • Well, my question is duplicate. In the link that you posted, there is an answer for my question. Thanks by the way. – yfklon Apr 24 '13 at 11:57

you must be knowing that Directory is nothing but a file that points to some list of files, basically it is a pointer, may be hidden or not. in similar way . and .. are the pointer which point to Uppermost directory and upper directory respectively. that is why i think when we execute

ls -a

command, these are displayed!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.