Results 1 to 5 of 5

Thread: Hard links shown in ls -l doesn't make sense!

  1. #1
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Hard links shown in ls -l doesn't make sense!

    Hi again,

    I have a folder "temp" and 2 files, one inside temp and another outside but pointing to the same file.

    The file names are t and tlink.


    eipe@eipe-john:~$ ls -l
    -rw-r--r-- 2 eipe eipe 6 2010-12-03 14:39 t
    drwxr-xr-x 2 eipe eipe 4096 2010-12-03 15:55 temp

    eipe@eipe-john:~/temp$ ls -la
    drwxr-xr-x 2 eipe eipe 4096 2010-12-03 15:55 .
    drwxr-xr-x 48 eipe eipe 4096 2010-12-03 15:54 ..
    -rw-r--r-- 2 eipe eipe 6 2010-12-03 14:39 tlink

    1. I understand that the second column shows the hard link count for files. But what does it show for directories like temp? It shows 2 even after deleting tlink.

    2. For the pointer .. it shows 48! what does it mean? Also .. are pointers, right?
    Last edited by john77eipe; December 3rd, 2010 at 01:24 PM.
    Regards,
    John Eipe
    http://www.developers-notebook.info

  2. #2
    Join Date
    May 2008
    Location
    London
    Beans
    330
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Hard links shown in ls -l doesn't make sense!

    Quote Originally Posted by john77eipe View Post
    1. I understand that the second column shows the hard link count for files. But what does it show for directories like temp? It shows 2 even after deleting tlink.
    The second column is the count of the number of subdirectories, if it is a directory. If it is a file, then it will be 1.

    An empty directory will read as 2. And having a file tlink in the temp directory doesn't change this.

    The 48 means you have 46 + (. and ..) directories in your home folder.

    Hope this helps.
    Value Linux Virtual/Shared Hosting - http://www.gigatux.com | Homepage - http://rampage.homelinux.com

  3. #3
    Join Date
    Apr 2005
    Location
    Finland/UK
    Beans
    Hidden!
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Hard links shown in ls -l doesn't make sense!

    the "." and ".." are files (or actually links) as well. "." links to current directory and ".." to parent directory.

    So even "empty" directory will always have these two files in it.

  4. #4
    Join Date
    Feb 2008
    Beans
    5,636

    Re: Hard links shown in ls -l doesn't make sense!


  5. #5
    Join Date
    Feb 2010
    Beans
    166
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Hard links shown in ls -l doesn't make sense!

    thanks a ton guys! I got it.
    Regards,
    John Eipe
    http://www.developers-notebook.info

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •