0

I run ls -la on the Volumes directory. It shows the MM dir to have 9 hard links and the Media dir to have 12. If I then cd to the MM directory and run ls -la, it shows only 7 items whereas if I cd to the Media dir, it has 12 as expected. Why does the MM dir have only 7 items? shouldn't it be 9?

1

Every directory has at least two references: one from its parent directory (the Volumes entry in /), and one from its own . entry.

If there are subdirectories, each has a .. entry that refers back to the parent, and those also contribute toward the parent's link count.

So your /Volumes directory's link count of 9 consists of one from /, plus one from itself, plus 7 from subdirectories.

  • no it contains 7 including the "/." and "/.." – 13uz Oct 4 '14 at 20:57
0

. represents the current directory, where as .. represents the parent directory.

For example, currently I am in demo directory

$cd demo/dir1
$pwd
/home/guru/demo/dir1       <-  my current directory
$cd .
$pwd
/home/guru/demo/dir1       <-  cd again to my current directory
cd ..
$pwd
/home/guru/demo           <-  cd  to parent directory

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.