Linux – Why create a link like this: ln -nsf

command linelinux

What does this do?

ln -nsf

I know ln -s creates a symbolic link, not a hard link which means you can delete it and it won't delete the think that it's linking to. But what do the other things mean? (-nf)

Update: okay…so I remembered you can find this stuff out from the command line. Here's what I found out from typing ln --help:

-f, --force                 remove existing destination files
-n, --no-dereference        treat destination that is a symlink to a
                            directory as if it were a normal file

But this still isn't very clear to me what the implications of this are. Why would I want to create a soft/sym link like this?

Best Answer

From the BSD man page:

 -f    If the target file already exists, then unlink it so that the link
           may occur.  (The -f option overrides any previous -i options.)

 -n    If the target_file or target_dir is a symbolic link, do not follow
           it.  This is most useful with the -f option, to replace a symlink
           which may point to a directory.
Related Question