3

So there was a file dummy1. I created a symlink:

ln -snf dummy dummy1

and confused source and target file, as I actually wanted dummy to point to dummy1 not vice versa. So now dummy1 is a symlink.

Is the original dummy1 file removed by doing this? Any way to get it back?

I would expect to get it back somehow, because otherwise that would be strange, as even rm command asks for confirmation.

Thank you

1 Answers1

5

I hope you have a backup of dummy1! From the man page for ln:

   -f, --force
          remove existing destination files

So dummy1 has been removed and replaced by the symlink.

If you want to prevent this in the future, do not use the -f flag to ln.

jayhendren
  • 8,384
  • 2
  • 33
  • 58
  • thanks for pointing it out! I actually checked man, but on my mac, which says -f If the target file already exists, then unlink it so that the link may occur. So it was not clear for me that it was removed and I didn't know that on linux (which is the question about) it says differently – rightaway717 Nov 22 '16 at 16:19
  • 2
    @rightaway717 "unlink" means "remove" in the Unix world. – Stephen Kitt Nov 22 '16 at 16:20
  • @StephenKitt good to know that now, though too late. I didn't know there is such a command, thanx – rightaway717 Nov 22 '16 at 16:23