Search code examples
unixdirectoryhyperlinkls

Basic UNIX link count


Why is the link count 2?

$ mkdir testdir
$ ls -ld testdir
drwxr-xr-x  2 me  you  68 Mar 29 12:34 testdir/

Perhaps it refers to a link to itself and link from parent directory?

I'm just reading through The UNIX Programming Environment and learning the basics.


Solution

  • When you create a directory, it always has two (special) subdirectories: . and .., which refer to the directory itself and its parent, respectively. If you add more sub directories, the link count increases from there.