This page on inodes has been exceptional help in grasping the surface-level concept of file systems. On the same page, the author has inserted this snippet demonstrating that each file or directory has at least 2 names (and hard links):
/tmp/junk$ ls -id ..
327681 ..
/tmp/junk$ cd ..
/tmp$ ls -id .
327681 .
We can see that /tmp has 3 hard links:
- Presumably, an inode for the filename “tmp”
- The same inode for the name “..”
- The same inode for the name “.”
My question: can the “junk” file in the /tmp directory also have 3 names (and hard links) if it is given a child directory? For example, /tmp/junk/paper_balls.
My hypothesis: If the “junk” file becomes a parent, it can be invoked with .. but relatively, meaning the current working directory (from which .. is typed) would have to be within the directory path /tmp/. The answer to my question is probably too advanced.
ls -ltells you the hard link count. It may be relatively meaningless information, but it’s nice to be able to read command results like a name badge. I was thinking each inode created a hard link.mkdir junk; cd junk; ls -lid .;mkdir foo; ls -lid .; mkdir bar; ls -lid .; mkdir baz; ls -lid .should clarify what is happening.