Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
    
See Create symlink - overwrite if one exists for more details. – Stephen Kitt 1 hour ago

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.

share|improve this answer
    
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 1 hour ago
2  
@rightaway717 "unlink" means "remove" in the Unix world. – Stephen Kitt 1 hour ago
    
@StephenKitt good to know that now, though too late. I didn't know there is such a command, thanx – rightaway717 1 hour ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.