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

4
  • / is the home directory of some system users on many systems. So that assignment is bit confusing. What's a PC pool? Dec 2, 2014 at 10:48
  • Yeap, i guess we use all the same Home directory. Just everybody gots his account (example: pool14:/home/myusername>
    – Marko
    Dec 2, 2014 at 10:57
  • 1
    Where do people get UNIX homework from? lol. Dec 2, 2014 at 11:25
  • @DisplayName People like me who teach it :)
    – SailorCire
    Dec 2, 2014 at 13:29

1 Answer 1

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.

3
  • So is that the way i can do it in Xterm? Sorry, im still total new to unix/linux. :S
    – Marko
    Dec 2, 2014 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. Dec 2, 2014 at 11:28
  • It´s never late to learn something new! :) But, thx for the answer, it works :)
    – Marko
    Dec 2, 2014 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .