When one tries to force the creation of a symlink by using -f option, nothing happens. I'm using the latest coreutils package (5.2.1-r6) Example: stan src # cd /usr/src stan src # ls -l total 4 lrwxrwxrwx 1 root root 22 авг 2 20:20 linux -> linux-2.6.12-gentoo-r7 drwxr-xr-x 19 root root 4096 авг 10 17:33 linux-2.6.12-gentoo-r7 stan src # ln -s -f foo linux stan src # ls -l total 4 lrwxrwxrwx 1 root root 22 авг 2 20:20 linux -> linux-2.6.12-gentoo-r7 drwxr-xr-x 19 root root 4096 авг 10 17:49 linux-2.6.12-gentoo-r7 stan src # ln -s foo linux ln: `linux/foo': File exists Reproducible: Always Steps to Reproduce:
your foo symlink is being created inside of linux/ looks like ln dereferences the target before creating the symlink, but the -f option is working fine (as your example shows)
From the manpage: -n, --no-dereference When given an explicit destination that is a symlink to a directory, treat that des- tination as if it were a normal file. When the destination is an actual directory (not a symlink to one), there is no ambiguity. The link is created in that directory. But when the specified destina- tion is a symlink to a directory, there are two ways to treat the user's request. ln can treat the destination just as it would a normal directory and create the link in it. On the other hand, the destination can be viewed as a non-directory -- as the symlink itself. In that case, ln must delete or backup that symlink before cre- ating the new link. The default is to treat a destination that is a symlink to a directory just like a directory. So this looks like the correct behaviour to me.
indeed, thanks for that