Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
4  
To not list . and .. you can use ls -A. –  Nykakin Apr 24 '13 at 12:01
add comment

3 Answers

up vote 14 down vote accepted

. 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.

share|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
add comment

. 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.

share|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. –  blank Apr 24 '13 at 11:57
add comment

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!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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