How do I create a symbolic link [duplicate]
I was wondering how to create a symbolic link in Ubuntu (12.04 LTS). I've done this before but this time it is a little different.
This command worked before.
user@desktop:/media/backup/folder$ ln -sv file.ods /home/user/file.ods
The last time I I created a file from my backup drive [harddisk].
Now I would like to create a symbolic link to a file present on a fileserver.
This is a virtual machine and probably a network connection to it is required. The fileserver (networkshare) is mounted at /media/fileserver.
I did try to use the same command as mentioned above, however, it create an empty file when opened it askes to be deleted because it is empty and useless.
When I do the command from above, it does not work. So, can someone help me out here?
Solution 1:
The syntax of ln
command is:
ln [options] <target file> [link name]
So, this command should work:
ln -sv /media/fileserver/anotherfile.ods /home/user/anotherfile.ods
The s
option creates a symbolic link, if omitted a hard link will be created. v
means "be verbose", i.e. ln
will show what it's doing.
You could also cd
to target's directory first:
cd /media/fileserver
ln -sv anotherfile.ods /home/user/anotherfile.ods
Or cd
to destination directory:
cd /home/user/
ln -sv /media/fileserver/anotherfile.ods
If you omit the link name, target's name is used. The above command creates a link to /media/fileserver/anotherfile.ods
in /home/user/anotherfile.ods
.