How can I avoid 'are the same file' error when using 'ln' in Linux?

240 views Asked by At

I'm trying to link a directory to another location. Using the following command

ln -sf . dot

succeeds the first time, but it returns an error the second time:

ln -sf . dot

Output:

ln: '.' and 'dot/.' are the same file

This was on UbuntuĀ 16.04.12 (Xenial Xerus).

How can I avoid this error?

1

There are 1 answers

1
KamilCuk On BEST ANSWER

You can use ln -n to not dereference the existing symbolic link. See man ln.

ln -nsf . dot