When I create a new directory it contain 2 hard links and when I go inside to the new directory it contain two directories (. and ..) . has hard link count 2 and .. has hard link count 3, but I learn that directory can not contain more than one hard link. can anyone explain this scenario ?


Every directory has a link to itself and its parent (that's why . of an empty directory will have a link count of 2). But because every directory links to its parent, any directory that has a subdirectory will have a link from that child. Thus the link count of a directory is 2 + the number of directories immediately contained by it.

  • I have a small query as to if this is 100% right. Link count means the total number of ways you can access this directory right? In that case, one way to access this directory would be to use '.' whereas the second way to do so would be to use the fully qualified pathname to that directory. Hence the link count of 2. So the second link may not be the one pointing to the parent directory as you said (I think). Would be better if anyone could reinforce either of our statements. – posixKing Sep 10 '16 at 6:04

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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