Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
You need to use the full path of the file to which you're linking. –  HalosGhost Aug 9 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 –  richard Aug 10 at 22:28

3 Answers 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/users9000/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 SymcolicLink.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.

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer
    
i see. I thought i would be behave as a shortcut –  user3552926 Aug 9 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 at 20:33
    
Unfortunately no. I did the same long ago :) –  Willian Paixao Aug 9 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 at 20:41

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.