funny directory?

Kurt Granroth plug-discuss at granroth.org
Thu Sep 7 11:39:17 MST 2006


On Thursday 07 September 2006 11:02, Dazed_75 wrote:
> -rw-r--r-- 1 root root 1554 2006-09-06 09:00 dhclient.conf
> -rw-r--r-- 1 root root 1566 2005-09-14 17:41 dhclient.conf~
> drwxr-xr-x 2 root root 4096 2006-07-13 15:03 dhclient-enter-hooks.d
> drwxr-xr-x 2 root root 4096 2006-06-07 21:33 dhclient-exit-hooks.d
> -rwxr-xr-x 1 root root 8322 2006-05-05 08:02 dhclient-script
[snip]
> Notice the 1's and 2's before the owner names?  I was checking what
> they might be and tried this.  That digit is still unexplained (to me)
> but it was the reason I tried this.

The 1's and 2's show how many hard links are associated with that particular 
label.  In the case of files, it refers to the number of hard links to that 
same file data.  In the case of directories, it refers to the number of other 
directories contained within.

That means that files will start off with a count of 1.  Directories always 
start off with 2 since they always have '.' and '..'  It's not reliable to 
use that to detect if a label is a directory or not, though, since a file 
with another hard link would show up as '2' as well.

A more reliable way of detecting the type using 'ls' is to look at the first 
character in the permissions.  Note that for all of the regular files, the 
first char is '-' but for the directories, it is 'd'.


More information about the PLUG-discuss mailing list