As per the question, I am thinking
mkdir ~/a is either two or three:
- 1 entry for the dir it sits in (
- 1 entry for itself (
cd a && ls .)
- and/or 1 entry for itself again (
cd a && ls ..)
Could someone clarify if this is two or three?
In an empty directory:
As you can see there are 2 links to an empty directory. When I create a new one inside it the link count increases to 3. Additionaly there are 2 links to the new directory. The total is 3 new links.
This is because every directory has a link to itself (.) and its parent (..) .
In the original Unix implementation, in order to keep the filesystem code inside the kernel simple, directory manipulation programs did some extra work: in particular,
Pretty soon the code for
Nowadays, some (most?) filesystems fake it: directories don't actually have
By reference, not by name. So if you rename