Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please explain me what is use of -links option in find command. The man page is not giving much information. Some of our scripts we are using have an option -links 0 in find command.

I am using the following command to do so.

find /data -type f -links 0 -ls
share|improve this question
up vote 1 down vote accepted

On Linux, files data are stored into inodes, which are nameless. Each time you create a link to a file (hardlink), ie you add it a name, this link count is increased. If you rm one file, then the link count is decreased. When it reaches 0, file is deleted.

In some cases, deletion don't happen. We're then talking about orphaned inode (data but no one pointing to them). Link count is then equal to 0.

Any file you can see using ls or any file browser has at least a link count equal to 1.

share|improve this answer
Thank You for such a wonderful explanation. – Sriharsha Kalluru Jan 2 '13 at 8:23
How would a file have multiple links?? The same data written on multiple files?? I see that many files have multiple links so it is commonly used! – amyassin Jan 2 '13 at 8:31
@amyassin the see the real amount of links, use: stat command on a file. You'll see that most of them have a single link. If you see more than 1, then you have a hardlink (symlinks don't follow that logic). And yes, it means that the same data are written in multiple files. While they exist only once on the disk. – Heis Spiter Jan 2 '13 at 8:47

Well, right from the man page:

-links n
    File has n links.

So in the command you posted, it would filter on files with zero links.

share|improve this answer
Thanks for the information, Is that mean that if the files wont have any links will be listed? – Sriharsha Kalluru Jan 2 '13 at 8:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.