8

This question already has an answer here:

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?

marked as duplicate by Radu Rădeanu, Alvar, Basharat Sialvi, Kevin Bowen, Jorge Castro Jul 17 '13 at 2:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

17

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.

  • Beautiful examples. Additionally I think it would be good to include the meanings of -sv. – itsols Nov 16 '13 at 13:36
  • @itsols Thanks. I included the information about those options. – Eric Carvalho Nov 16 '13 at 13:55
  • 1
    The last two commands are ls instead of ln. Is this on purpose? – Max Damage Mar 25 '15 at 10:56
  • @MaxDamage Indeed, it should be ln. I must have been drunk when I typed it. :-O Thanks. – Eric Carvalho Mar 25 '15 at 11:10

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