Go to the first, previous, next, last section, table of contents.


How to identify a file with multiple links

For a given file, named file, you can see by doing `ls -l file'; the number of links is shown in the second column, i.e. after the permission bits and before the file owner's username.

To find all regular files in a given set of directories topdirs (and their subdirectories) that have more than one link, do `find topdirs -type f -links +1'. (To find the files that only have a single link, change the `-links +1' to `-links 1'.)

Other useful options to `find' are `-xdev' (which stops find from trying to descend other filesystems (especially `/proc', which would usually result in a lot of error messages being printed out)); and `-fstype ext2' (which is useful in the context `find / -fstype ext2 ...', which is a simpler way of writing `find `sed -n 's/^[^ ]* \([^ ]*\) ext2 .*/\1/p' /proc/mounts` ...', both of which go through all ext2 filesystems currently mounted).


Go to the first, previous, next, last section, table of contents.