Super User is a question and answer site for computer enthusiasts and power users. 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

SSH is a soft link (symbolic link or symlink) to dropbear.

I want to know how many files are soft linked to dropbear. Is there any method to find how many soft links point to certain file?

It would be better if it also shows a list of soft links which point to that file.

/usr/bin/ssh -l
lrwxrwxrwx    1 root     root           16 Apr 22  2011 /usr/bin/ssh -> ../sbin/dropbear
share|improve this question

I came up with this chain:

find . -type l -ls | egrep -o -- '-> .+$' | sort | uniq -c

It lists all symbolic links, greps for whatever comes after ->, sorts it and groups it.

It is a first step, but by far not perfect. You can run find on / to get a big list, but if the symbolic link is to a relative target, the command will group them together even if they are not the same.


/home/shi/bin/ -> ./
/home/shi/sbin/ -> ./ might be different programs - one in bin and another one in sbin.

Another issue are regular file names with -> in them (not very common, though). The format of ls cannot distinguish this.

Example: -> ->

A file called might link to -> or a file called -> might link to

I hope this helps in your case. For a perfect solution you should use a script (sh, PHP, Perl).

share|improve this answer

If you don't need to check across filesystems you could use symlinks:

symlinks -rsv / | grep | tee >(wc -l)

the above should output a list of links that point to a file as well as count their number:

absolute: /usr/bin/ -> /usr/share/acpi_call/
absolute: /root/linkone -> /usr/share/acpi_call/
relative: /root/rellinktwo -> ../usr/share/acpi_call/

man symlinks for more details.

share|improve this answer

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.