Both programs stat
and ls -l
tell about the number of (hard) links to file(s).
Going under the assumption that one usually cannot create hardlinks for directories in Linux it confuses me to see outputs like this
$ ls / -l | grep etc
drwxr-xr-x 163 root root 12288 Oct 11 17:32 etc
$ stat /etc | grep Links
Device: fc00h/64512d Inode: 655361 Links: 163
Are there indeed 163 links to etc? I am confused and I would like to know what the number of links means with respect to directories?
I have tested that creating symbolic links does not have an influence to the number (which seems logic as the system would have hell of a job to keep track of all symbolic links)
Also I have tested that for regular files the number really reflects the hardlinks.
.
and..
are hardlinks. In your case/etc
has 161 subdirectories, all of whom contain a..
hardlink to it. See here and here. – jw013 Oct 11 '14 at 19:13..
. Thanks for clearing my confusion. This also gives the reason why the linkcount always ever starts with 2 for newly made directories. – humanityANDpeace Oct 11 '14 at 19:17find /etc/ -type l -iname "*" |wc -l
– PersianGulf Oct 11 '14 at 19:32