Linux – “ln -L” (–logical) for

hardlinklinuxlnproc

I can read in the ln man page:

   -L, --logical
          make hard links to symbolic link references

I read somewhere that ln -L could be used to re-link files that were deleted but which are still open, using the /proc filesystem. For example:

ln -L /proc/1234/fd/12 /tmp/my-file

But I'm getting ENOENT: No such file or directory. If I try on a different filesystem, I get instead Invalid cross-device link.

If I can't use ln -L to recover deleted files, then what could it be used for?

Best Answer

GNU utilities are primarily documented with info pages. From the GNU ln info page:

‘-L’
‘--logical’
    If -s is not in effect, and the source file is a symbolic link,
    create the hard link to the file referred to by the symbolic link,
    rather than the symbolic link itself. 

So this simply dereferences symbolic links given as source arguments.

Related Question