Documents folder has 7 hard links












4















When tried the command



me@me:~$ ls -hl | head -5                                                                 
total 60M
-rw-r--r-- 1 me me 250 Jan 16 11:43 $tty
-rw-r--r-- 1 me me 0 Jan 16 11:41 1
drwxr-xr-x 2 me me 4.0K Jan 16 15:28 Desktop
drwxr-xr-x 7 me me 4.0K Jan 13 14:33 Documents


Found that Documents directory has 7 hard links, what's the reason for such a redundancy?










share|improve this question







New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • What are the content of Document directory ?

    – Soren A
    18 hours ago






  • 1





    One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

    – AlexP
    18 hours ago













  • smart, could you please transmit the comment to answer. @AlexP

    – Alice
    18 hours ago











  • All right, done.

    – AlexP
    17 hours ago






  • 2





    AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

    – Sergiy Kolodyazhnyy
    15 hours ago
















4















When tried the command



me@me:~$ ls -hl | head -5                                                                 
total 60M
-rw-r--r-- 1 me me 250 Jan 16 11:43 $tty
-rw-r--r-- 1 me me 0 Jan 16 11:41 1
drwxr-xr-x 2 me me 4.0K Jan 16 15:28 Desktop
drwxr-xr-x 7 me me 4.0K Jan 13 14:33 Documents


Found that Documents directory has 7 hard links, what's the reason for such a redundancy?










share|improve this question







New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • What are the content of Document directory ?

    – Soren A
    18 hours ago






  • 1





    One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

    – AlexP
    18 hours ago













  • smart, could you please transmit the comment to answer. @AlexP

    – Alice
    18 hours ago











  • All right, done.

    – AlexP
    17 hours ago






  • 2





    AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

    – Sergiy Kolodyazhnyy
    15 hours ago














4












4








4








When tried the command



me@me:~$ ls -hl | head -5                                                                 
total 60M
-rw-r--r-- 1 me me 250 Jan 16 11:43 $tty
-rw-r--r-- 1 me me 0 Jan 16 11:41 1
drwxr-xr-x 2 me me 4.0K Jan 16 15:28 Desktop
drwxr-xr-x 7 me me 4.0K Jan 13 14:33 Documents


Found that Documents directory has 7 hard links, what's the reason for such a redundancy?










share|improve this question







New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












When tried the command



me@me:~$ ls -hl | head -5                                                                 
total 60M
-rw-r--r-- 1 me me 250 Jan 16 11:43 $tty
-rw-r--r-- 1 me me 0 Jan 16 11:41 1
drwxr-xr-x 2 me me 4.0K Jan 16 15:28 Desktop
drwxr-xr-x 7 me me 4.0K Jan 13 14:33 Documents


Found that Documents directory has 7 hard links, what's the reason for such a redundancy?







filesystem






share|improve this question







New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 19 hours ago









AliceAlice

1499




1499




New contributor




Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Alice is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • What are the content of Document directory ?

    – Soren A
    18 hours ago






  • 1





    One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

    – AlexP
    18 hours ago













  • smart, could you please transmit the comment to answer. @AlexP

    – Alice
    18 hours ago











  • All right, done.

    – AlexP
    17 hours ago






  • 2





    AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

    – Sergiy Kolodyazhnyy
    15 hours ago



















  • What are the content of Document directory ?

    – Soren A
    18 hours ago






  • 1





    One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

    – AlexP
    18 hours ago













  • smart, could you please transmit the comment to answer. @AlexP

    – Alice
    18 hours ago











  • All right, done.

    – AlexP
    17 hours ago






  • 2





    AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

    – Sergiy Kolodyazhnyy
    15 hours ago

















What are the content of Document directory ?

– Soren A
18 hours ago





What are the content of Document directory ?

– Soren A
18 hours ago




1




1





One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

– AlexP
18 hours ago







One from ., one from its name in the parent directory, and five from the .. in five subdirectories?

– AlexP
18 hours ago















smart, could you please transmit the comment to answer. @AlexP

– Alice
18 hours ago





smart, could you please transmit the comment to answer. @AlexP

– Alice
18 hours ago













All right, done.

– AlexP
17 hours ago





All right, done.

– AlexP
17 hours ago




2




2





AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

– Sergiy Kolodyazhnyy
15 hours ago





AlexP's answer is spot on. Also you might be interested in this post, specifically this part (and example after it):"Thus, for a directory link the inode count is minimum 2 for a bare directory (link to parent .. and link to self .), and each additional subdirectory is an extra link/node:"

– Sergiy Kolodyazhnyy
15 hours ago










2 Answers
2






active

oldest

votes


















9














If the directory Documents has seven hard links, this means that:




  • One hard link is from the name Documents in its parent directory.


  • One hard link is from the entry . in Documents itself.


  • Five hard links are from the entries .. in five subdirectories.







share|improve this answer































    3














    Column #2 in the output of ls -l shows the number of hard links(?)



    Folders alias directories cannot be hard-linked (but they can be linked to with symbolic links). The number in the same place as number of hard links for files means something else, related to how much space the folder needs in the file system's 'table', because the number grows with the number of sub-folders.



    Hard links means that the data at a certain inode are pointed to by more than one file name (so the hard-linked names share the same inode number).



    There is a detailed explanation by Sergiy Kolodyazhnyy at this link and this comment by him,




    Folders alias directories cannot be hard-linked by the users, since it
    would create issues with filesystem. Filesystem itself does allow
    hard-links in a very controlled manner, which is .. and . special
    entries. Size, however, is shown in most cases to be 4096 bytes (see
    this related post), but if I am not mistaken, directory with large number
    of entries can go over that number. This may be worth adding to the
    answer




    Column #5 in the output of ls -l shows the file size(?)



    But what about directories -- most directories occupy 4 kiB, but when there are many files (and directories) the names cannot get squeezed into 4kiB and more space will be allocated, 8 kiB, 12 kiB etc. My 'worst' case is a Firefox cache directory with the 'size' 4012 kiB. It contains 58971 files, and these files occupy 2.2 GiB. This reminds me that it is getting time the clear the Firefox cache ;-)





    You can check that your Documents folder's inode number is unique, no other file or folder shares it. You can check other folders too.



    Try the following commands (maybe modified, if you have another language (than English).





    • Identify the inode number (you will get another number than I)



      $ls -lid ~/Documents/
      3017032 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents/



    • Search for files/folders with that inode number (and try to avoid too many warning/error outputs)



      $ sudo find / -path /proc -prune -o -ls | grep ' 3017032 '
      [sudo] password for sudodus:
      3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
      find: ‘/run/user/1000/gvfs’: Permission denied


      or



      $ sudo find / -inum 3017032  -ls
      3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
      find: '/proc/1643/task/1643/net': Invalid argument
      find: '/proc/1643/net': Invalid argument
      find: '/proc/1741/task/1741/net': Invalid argument
      find: '/proc/1741/net': Invalid argument
      find: '/proc/4021': No such file or directory
      find: '/proc/4038': No such file or directory
      find: '/proc/4039': No such file or directory
      find: '/run/user/1000/gvfs': Permission denied





    The following example shows the corresponding case with three hard-linked file names.





    • Identify the inode number



      $ ls -il owned by root
      56492055 -rw-r--r-- 3 root root 1048576 jan 16 23:41 'owned by root'



    • Search within the file system (in this case my data partition)



      $ sudo find /media/multimed-2/ -inum 56492055
      [sudo] password for sudodus:
      /media/multimed-2/test/test0/owned by root hard-linked
      /media/multimed-2/test/test0/owned by root
      /media/multimed-2/test/test0/sub/owned by root







    share|improve this answer





















    • 1





      Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

      – Sergiy Kolodyazhnyy
      15 hours ago













    • Thanks, @SergiyKolodyazhnyy :-)

      – sudodus
      14 hours ago











    • Always glad to help :)

      – Sergiy Kolodyazhnyy
      14 hours ago






    • 1





      Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

      – PerlDuck
      11 hours ago






    • 1





      @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

      – Sergiy Kolodyazhnyy
      8 hours ago











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Alice is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1110532%2fdocuments-folder-has-7-hard-links%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    9














    If the directory Documents has seven hard links, this means that:




    • One hard link is from the name Documents in its parent directory.


    • One hard link is from the entry . in Documents itself.


    • Five hard links are from the entries .. in five subdirectories.







    share|improve this answer




























      9














      If the directory Documents has seven hard links, this means that:




      • One hard link is from the name Documents in its parent directory.


      • One hard link is from the entry . in Documents itself.


      • Five hard links are from the entries .. in five subdirectories.







      share|improve this answer


























        9












        9








        9







        If the directory Documents has seven hard links, this means that:




        • One hard link is from the name Documents in its parent directory.


        • One hard link is from the entry . in Documents itself.


        • Five hard links are from the entries .. in five subdirectories.







        share|improve this answer













        If the directory Documents has seven hard links, this means that:




        • One hard link is from the name Documents in its parent directory.


        • One hard link is from the entry . in Documents itself.


        • Five hard links are from the entries .. in five subdirectories.








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 17 hours ago









        AlexPAlexP

        7,55011428




        7,55011428

























            3














            Column #2 in the output of ls -l shows the number of hard links(?)



            Folders alias directories cannot be hard-linked (but they can be linked to with symbolic links). The number in the same place as number of hard links for files means something else, related to how much space the folder needs in the file system's 'table', because the number grows with the number of sub-folders.



            Hard links means that the data at a certain inode are pointed to by more than one file name (so the hard-linked names share the same inode number).



            There is a detailed explanation by Sergiy Kolodyazhnyy at this link and this comment by him,




            Folders alias directories cannot be hard-linked by the users, since it
            would create issues with filesystem. Filesystem itself does allow
            hard-links in a very controlled manner, which is .. and . special
            entries. Size, however, is shown in most cases to be 4096 bytes (see
            this related post), but if I am not mistaken, directory with large number
            of entries can go over that number. This may be worth adding to the
            answer




            Column #5 in the output of ls -l shows the file size(?)



            But what about directories -- most directories occupy 4 kiB, but when there are many files (and directories) the names cannot get squeezed into 4kiB and more space will be allocated, 8 kiB, 12 kiB etc. My 'worst' case is a Firefox cache directory with the 'size' 4012 kiB. It contains 58971 files, and these files occupy 2.2 GiB. This reminds me that it is getting time the clear the Firefox cache ;-)





            You can check that your Documents folder's inode number is unique, no other file or folder shares it. You can check other folders too.



            Try the following commands (maybe modified, if you have another language (than English).





            • Identify the inode number (you will get another number than I)



              $ls -lid ~/Documents/
              3017032 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents/



            • Search for files/folders with that inode number (and try to avoid too many warning/error outputs)



              $ sudo find / -path /proc -prune -o -ls | grep ' 3017032 '
              [sudo] password for sudodus:
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: ‘/run/user/1000/gvfs’: Permission denied


              or



              $ sudo find / -inum 3017032  -ls
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: '/proc/1643/task/1643/net': Invalid argument
              find: '/proc/1643/net': Invalid argument
              find: '/proc/1741/task/1741/net': Invalid argument
              find: '/proc/1741/net': Invalid argument
              find: '/proc/4021': No such file or directory
              find: '/proc/4038': No such file or directory
              find: '/proc/4039': No such file or directory
              find: '/run/user/1000/gvfs': Permission denied





            The following example shows the corresponding case with three hard-linked file names.





            • Identify the inode number



              $ ls -il owned by root
              56492055 -rw-r--r-- 3 root root 1048576 jan 16 23:41 'owned by root'



            • Search within the file system (in this case my data partition)



              $ sudo find /media/multimed-2/ -inum 56492055
              [sudo] password for sudodus:
              /media/multimed-2/test/test0/owned by root hard-linked
              /media/multimed-2/test/test0/owned by root
              /media/multimed-2/test/test0/sub/owned by root







            share|improve this answer





















            • 1





              Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

              – Sergiy Kolodyazhnyy
              15 hours ago













            • Thanks, @SergiyKolodyazhnyy :-)

              – sudodus
              14 hours ago











            • Always glad to help :)

              – Sergiy Kolodyazhnyy
              14 hours ago






            • 1





              Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

              – PerlDuck
              11 hours ago






            • 1





              @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

              – Sergiy Kolodyazhnyy
              8 hours ago
















            3














            Column #2 in the output of ls -l shows the number of hard links(?)



            Folders alias directories cannot be hard-linked (but they can be linked to with symbolic links). The number in the same place as number of hard links for files means something else, related to how much space the folder needs in the file system's 'table', because the number grows with the number of sub-folders.



            Hard links means that the data at a certain inode are pointed to by more than one file name (so the hard-linked names share the same inode number).



            There is a detailed explanation by Sergiy Kolodyazhnyy at this link and this comment by him,




            Folders alias directories cannot be hard-linked by the users, since it
            would create issues with filesystem. Filesystem itself does allow
            hard-links in a very controlled manner, which is .. and . special
            entries. Size, however, is shown in most cases to be 4096 bytes (see
            this related post), but if I am not mistaken, directory with large number
            of entries can go over that number. This may be worth adding to the
            answer




            Column #5 in the output of ls -l shows the file size(?)



            But what about directories -- most directories occupy 4 kiB, but when there are many files (and directories) the names cannot get squeezed into 4kiB and more space will be allocated, 8 kiB, 12 kiB etc. My 'worst' case is a Firefox cache directory with the 'size' 4012 kiB. It contains 58971 files, and these files occupy 2.2 GiB. This reminds me that it is getting time the clear the Firefox cache ;-)





            You can check that your Documents folder's inode number is unique, no other file or folder shares it. You can check other folders too.



            Try the following commands (maybe modified, if you have another language (than English).





            • Identify the inode number (you will get another number than I)



              $ls -lid ~/Documents/
              3017032 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents/



            • Search for files/folders with that inode number (and try to avoid too many warning/error outputs)



              $ sudo find / -path /proc -prune -o -ls | grep ' 3017032 '
              [sudo] password for sudodus:
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: ‘/run/user/1000/gvfs’: Permission denied


              or



              $ sudo find / -inum 3017032  -ls
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: '/proc/1643/task/1643/net': Invalid argument
              find: '/proc/1643/net': Invalid argument
              find: '/proc/1741/task/1741/net': Invalid argument
              find: '/proc/1741/net': Invalid argument
              find: '/proc/4021': No such file or directory
              find: '/proc/4038': No such file or directory
              find: '/proc/4039': No such file or directory
              find: '/run/user/1000/gvfs': Permission denied





            The following example shows the corresponding case with three hard-linked file names.





            • Identify the inode number



              $ ls -il owned by root
              56492055 -rw-r--r-- 3 root root 1048576 jan 16 23:41 'owned by root'



            • Search within the file system (in this case my data partition)



              $ sudo find /media/multimed-2/ -inum 56492055
              [sudo] password for sudodus:
              /media/multimed-2/test/test0/owned by root hard-linked
              /media/multimed-2/test/test0/owned by root
              /media/multimed-2/test/test0/sub/owned by root







            share|improve this answer





















            • 1





              Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

              – Sergiy Kolodyazhnyy
              15 hours ago













            • Thanks, @SergiyKolodyazhnyy :-)

              – sudodus
              14 hours ago











            • Always glad to help :)

              – Sergiy Kolodyazhnyy
              14 hours ago






            • 1





              Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

              – PerlDuck
              11 hours ago






            • 1





              @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

              – Sergiy Kolodyazhnyy
              8 hours ago














            3












            3








            3







            Column #2 in the output of ls -l shows the number of hard links(?)



            Folders alias directories cannot be hard-linked (but they can be linked to with symbolic links). The number in the same place as number of hard links for files means something else, related to how much space the folder needs in the file system's 'table', because the number grows with the number of sub-folders.



            Hard links means that the data at a certain inode are pointed to by more than one file name (so the hard-linked names share the same inode number).



            There is a detailed explanation by Sergiy Kolodyazhnyy at this link and this comment by him,




            Folders alias directories cannot be hard-linked by the users, since it
            would create issues with filesystem. Filesystem itself does allow
            hard-links in a very controlled manner, which is .. and . special
            entries. Size, however, is shown in most cases to be 4096 bytes (see
            this related post), but if I am not mistaken, directory with large number
            of entries can go over that number. This may be worth adding to the
            answer




            Column #5 in the output of ls -l shows the file size(?)



            But what about directories -- most directories occupy 4 kiB, but when there are many files (and directories) the names cannot get squeezed into 4kiB and more space will be allocated, 8 kiB, 12 kiB etc. My 'worst' case is a Firefox cache directory with the 'size' 4012 kiB. It contains 58971 files, and these files occupy 2.2 GiB. This reminds me that it is getting time the clear the Firefox cache ;-)





            You can check that your Documents folder's inode number is unique, no other file or folder shares it. You can check other folders too.



            Try the following commands (maybe modified, if you have another language (than English).





            • Identify the inode number (you will get another number than I)



              $ls -lid ~/Documents/
              3017032 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents/



            • Search for files/folders with that inode number (and try to avoid too many warning/error outputs)



              $ sudo find / -path /proc -prune -o -ls | grep ' 3017032 '
              [sudo] password for sudodus:
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: ‘/run/user/1000/gvfs’: Permission denied


              or



              $ sudo find / -inum 3017032  -ls
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: '/proc/1643/task/1643/net': Invalid argument
              find: '/proc/1643/net': Invalid argument
              find: '/proc/1741/task/1741/net': Invalid argument
              find: '/proc/1741/net': Invalid argument
              find: '/proc/4021': No such file or directory
              find: '/proc/4038': No such file or directory
              find: '/proc/4039': No such file or directory
              find: '/run/user/1000/gvfs': Permission denied





            The following example shows the corresponding case with three hard-linked file names.





            • Identify the inode number



              $ ls -il owned by root
              56492055 -rw-r--r-- 3 root root 1048576 jan 16 23:41 'owned by root'



            • Search within the file system (in this case my data partition)



              $ sudo find /media/multimed-2/ -inum 56492055
              [sudo] password for sudodus:
              /media/multimed-2/test/test0/owned by root hard-linked
              /media/multimed-2/test/test0/owned by root
              /media/multimed-2/test/test0/sub/owned by root







            share|improve this answer















            Column #2 in the output of ls -l shows the number of hard links(?)



            Folders alias directories cannot be hard-linked (but they can be linked to with symbolic links). The number in the same place as number of hard links for files means something else, related to how much space the folder needs in the file system's 'table', because the number grows with the number of sub-folders.



            Hard links means that the data at a certain inode are pointed to by more than one file name (so the hard-linked names share the same inode number).



            There is a detailed explanation by Sergiy Kolodyazhnyy at this link and this comment by him,




            Folders alias directories cannot be hard-linked by the users, since it
            would create issues with filesystem. Filesystem itself does allow
            hard-links in a very controlled manner, which is .. and . special
            entries. Size, however, is shown in most cases to be 4096 bytes (see
            this related post), but if I am not mistaken, directory with large number
            of entries can go over that number. This may be worth adding to the
            answer




            Column #5 in the output of ls -l shows the file size(?)



            But what about directories -- most directories occupy 4 kiB, but when there are many files (and directories) the names cannot get squeezed into 4kiB and more space will be allocated, 8 kiB, 12 kiB etc. My 'worst' case is a Firefox cache directory with the 'size' 4012 kiB. It contains 58971 files, and these files occupy 2.2 GiB. This reminds me that it is getting time the clear the Firefox cache ;-)





            You can check that your Documents folder's inode number is unique, no other file or folder shares it. You can check other folders too.



            Try the following commands (maybe modified, if you have another language (than English).





            • Identify the inode number (you will get another number than I)



              $ls -lid ~/Documents/
              3017032 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents/



            • Search for files/folders with that inode number (and try to avoid too many warning/error outputs)



              $ sudo find / -path /proc -prune -o -ls | grep ' 3017032 '
              [sudo] password for sudodus:
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: ‘/run/user/1000/gvfs’: Permission denied


              or



              $ sudo find / -inum 3017032  -ls
              3017032 4 drwxr-xr-x 2 sudodus sudodus 4096 feb 28 2016 /home/sudodus/Documents
              find: '/proc/1643/task/1643/net': Invalid argument
              find: '/proc/1643/net': Invalid argument
              find: '/proc/1741/task/1741/net': Invalid argument
              find: '/proc/1741/net': Invalid argument
              find: '/proc/4021': No such file or directory
              find: '/proc/4038': No such file or directory
              find: '/proc/4039': No such file or directory
              find: '/run/user/1000/gvfs': Permission denied





            The following example shows the corresponding case with three hard-linked file names.





            • Identify the inode number



              $ ls -il owned by root
              56492055 -rw-r--r-- 3 root root 1048576 jan 16 23:41 'owned by root'



            • Search within the file system (in this case my data partition)



              $ sudo find /media/multimed-2/ -inum 56492055
              [sudo] password for sudodus:
              /media/multimed-2/test/test0/owned by root hard-linked
              /media/multimed-2/test/test0/owned by root
              /media/multimed-2/test/test0/sub/owned by root








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 14 hours ago

























            answered 15 hours ago









            sudodussudodus

            23.4k32874




            23.4k32874








            • 1





              Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

              – Sergiy Kolodyazhnyy
              15 hours ago













            • Thanks, @SergiyKolodyazhnyy :-)

              – sudodus
              14 hours ago











            • Always glad to help :)

              – Sergiy Kolodyazhnyy
              14 hours ago






            • 1





              Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

              – PerlDuck
              11 hours ago






            • 1





              @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

              – Sergiy Kolodyazhnyy
              8 hours ago














            • 1





              Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

              – Sergiy Kolodyazhnyy
              15 hours ago













            • Thanks, @SergiyKolodyazhnyy :-)

              – sudodus
              14 hours ago











            • Always glad to help :)

              – Sergiy Kolodyazhnyy
              14 hours ago






            • 1





              Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

              – PerlDuck
              11 hours ago






            • 1





              @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

              – Sergiy Kolodyazhnyy
              8 hours ago








            1




            1





            Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

            – Sergiy Kolodyazhnyy
            15 hours ago







            Directories cannot be hard-linked by the users, since it would create issues with filesystem. Filesystem itself does allow hard-links in a very controlled manner, which is .. and . special entries. Size, however, is shown in most cases to be 4096 bytes ( see related post ), but if I am not mistaken, directory with large number of entries can go over that number. This may be worth adding to the answer

            – Sergiy Kolodyazhnyy
            15 hours ago















            Thanks, @SergiyKolodyazhnyy :-)

            – sudodus
            14 hours ago





            Thanks, @SergiyKolodyazhnyy :-)

            – sudodus
            14 hours ago













            Always glad to help :)

            – Sergiy Kolodyazhnyy
            14 hours ago





            Always glad to help :)

            – Sergiy Kolodyazhnyy
            14 hours ago




            1




            1





            Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

            – PerlDuck
            11 hours ago





            Anecdote: on some machines we have a directory that (sometimes) stores many files, often 300,000 or thereabouts, but they also get deleted after a while. Think of some kind of spool directory. ls -l for that directory shows ~650 links and a size (5th column) of almost 100 MB. It holds 5 GB of data and ~19,000 files. I assume the value in this 5th column never shrinks but only grows. The only way to shrink that size is to copy the contents to a tmp directory and then replace the directories.

            – PerlDuck
            11 hours ago




            1




            1





            @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

            – Sergiy Kolodyazhnyy
            8 hours ago





            @PerlDuck You got me curious about it, so unix.stackexchange.com/q/495176/85039

            – Sergiy Kolodyazhnyy
            8 hours ago










            Alice is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Alice is a new contributor. Be nice, and check out our Code of Conduct.













            Alice is a new contributor. Be nice, and check out our Code of Conduct.












            Alice is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1110532%2fdocuments-folder-has-7-hard-links%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Loup dans la culture

            How to solve the problem of ntp “Unable to contact time server” from KDE?

            ASUS Zenbook UX433/UX333 — Configure Touchpad-embedded numpad on Linux