1

i got a homework today. Can u help me guys?

"Determine on any PC pool that hosts regular file on the local file system root who has the most hard links! Avoid doing a search of the user home directories or other NFS mounted directories. Type a file name of an regular file, the number of hard links, and a command that you could have a look at all the name of this file!"

With best regards! Marko

Marko
  • 11

1 Answers1

0

file with most hardlinks

You can use the commands

  1. find with the (GNU?) option -xdev, and the command -printf and its directives %n and %p
  2. sort -rn
  3. head -n 1

Of course, there may be different files (inodes) with the same number of hardlinks. If finding one of them is not enough then the solution becomes more complicated.

finding the other paths to a file / inode

You can use the command find with the option -xdev, and the test -samefile.

Hauke Laging
  • 90,279
  • So is that the way i can do it in Xterm? Sorry, im still total new to unix/linux. :S – Marko Dec 02 '14 at 11:16
  • 1
    Yes, these commands are run in a shell like the one running in xterm. Hard to believe that you get such homework without being familiar with the basics. – Hauke Laging Dec 02 '14 at 11:28
  • It´s never late to learn something new! :) But, thx for the answer, it works :) – Marko Dec 02 '14 at 11:39