2

When creating a softlink how do add the path, I did the following:

ln -s file1.txt /home/user9000/Desktop/SymbolicLink.txt

When I see the softlink on the desktop it marks that the doc doesn't exist.

Am I doing something wrong?

  • You need to use the full path of the file to which you're linking. – HalosGhost Aug 9 '14 at 20:37
  • To create a relative link, and have auto-completion help you, then first cd to directory that you want the link in. Then ln -s ../../a/b/c or ln -s -T ../../a/b/c link – ctrl-alt-delor Aug 10 '14 at 22:28
3

The syntax of ln may seem counter-intuitive at first until you see the rationale behind it.

The syntax (for soft link creation) is

ln -s <TARGET> <LINK_NAME>

where <TARGET> is interpreted relative to the location of the soft link.

So when you say something like:

ln -s file1.txt /home/user9000/Desktop/SymbolicLink.txt

This means create the file /home/user9000/Desktop/SymbolicLink.txt as a symbolic link to the file /home/user9000/Desktop/file1.txt.

My guess is, you're trying to link to file1 which is in the current working directory. In such a case, you'll need to give its full path as in vinc17's answer

Note that if you create SymbolicLink.txt with the command you have shown above, it has the interesting side effect that whenever you move it to any other directory, it will be a symbolic link to a file named file1 in that directory. Whereas if you supply the full path to file1, the link will always point to that file no matter where you place it in that machine.

2

Your link is incorrect. You need:

ln -s "$PWD/file1.txt" /home/user9000/Desktop/SymbolicLink.txt

You can also create a relative link (starting with ../), but I suggest that you cd to /home/user9000/Desktop first to avoid making a mistake.

-1

Yes, the UI behaves differently. A softlink won't be shown as a icon in desktop. You need to copy and paste the file there or create a link using the graphical interface itself.

  • i see. I thought i would be behave as a shortcut – user3552926 Aug 9 '14 at 20:32
  • What OS and UI are you talking about? On all Linux distros I have dealt with, a softlink is shown as an icon in the directory where it's placed. – Joseph R. Aug 9 '14 at 20:33
  • Unfortunately no. I did the same long ago :) – Willian Paixao Aug 9 '14 at 20:34
  • @joseph-r we're talking about Ubuntu's Unity. If you create a symbolic link in the Desktop folder, it won't show in your desktop area. – Willian Paixao Aug 9 '14 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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