I'm trying to create a symlink in my home directory to a directories and files on my data partition. I've tried:
~/Documents$ ln -sv ~/Documents/saga /media/mariajulia/485f3e29-355c-4be3-b80a-1f5abd5604b6/mariajulia/Downloads/saga..docto create a symlink named saga in my Documents directory in my home folder. The terminal output is:
ln: failed to create symbolic link ‘/media/mariajulia/485f3e29-355c-4be3-b80a-1f5abd5604b6/mariajulia/Downloads/saga..doc’: File existsI was checking the content of ~/Documents with ls -a , there is nothing but . and ... In general my home folder is empty, it's just a fresh system installation.
5 Answers
This is a classical error... it's the other way around:
ln -s Existing-file New-name so in your case
ln -sv /media/mariajulia/485f3e29-355c-4be3-b80a-1f5abd5604b6/mariajulia/Downloads/saga..doc ~/Documents/saga should work. Note though:
if
~/Documents/sagaexists and is not a directory, you will have the error too;if
~/Documents/sagaexists and is a directory, the symbolic link will be~/Documents/saga/saga..doc(are you sure about the double dot?)if
~/Documents/sagadoes not exists, you symbolic link will be~/Documents/saga(as it is, no extension).
I have same error message
when redirecting
ln -s /usr/bin/nodejs /usr/bin/nodefrom node.js v0.10.25
to node.js v4.2.3
so I look at man lnand use
[OPTION]
-f, --force remove existing destination filesThis is work as I expected.
4As @Rmano responded in his answer the arguments were in the wrong order. I made the same mistake pretty often too. Thus I found a
Fool-proof way to create symbolic links
First go into the directory where you want to create the link
cd ~/Documents/sagaThen create the link with a single argument.
ln -s /very/long/path/to/target/Downloads/saga..docThis will create a link to the current directory with the same name as the target.
Just to add new information, you can remove the current symlink, then re-create the symlink.
rm ~/Documents/sagaThen re-create the symlink:
ln -sv /media/mariajulia/485f3e29-355c-4be3-b80a-1f5abd5604b6/mariajulia/Downloads/saga..doc ~/Documents/sagaHope this helps anyone who still faces 'file exists' error.
Might be unrelated.
For me the link was dead. Pointing to a non existing folder. When trying to replace it, it would fail with this message. ^
So a simple rm linkName was enough.