Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I stat a directory I get a listing that tell me there are 5 links to the directory.

stat dir

My question is how do I get information (names and locations) to all these 5 links?

share|improve this question
up vote 13 down vote accepted

You just need ls (or find).

When you create a directory, its link count starts at 2:

  • One for the directory itself
  • One for the . link inside itself

The other thing that increases the directory's link count is its subdirectories: they all have a .. entry linking back to their parent, adding one to its link count.

You can't hardlink directories in Linux, so these are the only things that count towards the link count - two plus number of subdirectories.

share|improve this answer
Interesting, I never put it together in my head that . and .. are just links. I've always thought of them as magic dots. – Banjer Jul 14 '12 at 14:21

Your Answer


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.