Sample Header Ad - 728x90

ls long listing column "number of hard links": What does that mean?

0 votes
0 answers
25 views
Please shed some light on that erratic, second column of
-l
, that numeric column between the 1st one - the permission string - and the third one - the user ownership. I just can't pin it down, what it means and predict or explain it for any sub-directory with known content. I know what a hard link is, and what not. I know that when you create a new file
, it has 1 hard link. When you use
anewfile samestuffdifferentname
, the directory containing the aforementioned now contains both files and both have a hard link number of 2, meaning that there is 1 specific content on the storage - with 2 names, not just 1. So, things in
-l
are clear to me for all listings of regular files, but as soon as a sub-directory is listed, things become erratic, unpredictable, unexpected for me. I've looked for the specific meaning in
--help
,
and
, in vein; most video tutorials just cover the meaning of that line superficially, if at all; same with web search results. I've hacked around with
,
and
, filtering files by permission string with or without
, but I just can't pin it down. For example:
~/Pictures/
According to
-l
this sub-directory of my home directory has a hard link number of 4 - but I've certainly never created any hard link of that file/directory. So, maybe 4 is constituted by the sub-directories content: Maybe 4 regular files, each containing just 1 hard link, and so a hard link number of 1? Or 3 regular files like that, but additionally that sub-directory also counts as 1, so, the sum of the sub-directory and its content constitutes the 4? Wrong! It contains 22 files: 2 sub-directories and 20 regular files - 18/20 are files with a file extension (image file extension) or .xcf. Please, let's get to the bottom of that column - once and for all.
Asked by futurewave (213 rep)
Feb 11, 2024, 10:14 AM