Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my symbolic link creating a file and not a folder?

I want a create a symbolic link to a folder. The follow command will create a file with the link name but I'm trying to link to the source folder. What am I doing wrong?

ln -s /Users/me/somefolder somefolder

This creates a file "somefolder" in my current directory. How do I create a symbolic link to the folder and it's contents?

Thanks!

like image 520
Nick Avatar asked Jul 27 '13 03:07

Nick


2 Answers

You need to use absolute path names to create the links. For example, I'm now at

$ pwd
/home/alex/my_folder

And I'm creating a symbolic link to the folder "directoryA" in a sub-directory under my pwd (present working directory):

 $ ln -s $PWD/directoryA $PWD/temp/link_to_directoryA

In this case variable $PWD holds absolute path to my working directory. You can surely use your absolute path without any variables like this:

 $ ln -s /home/alex/my_folder/directoryA /home/alex/my_folder/temp/link_to_directoryA
like image 63
Smartens Avatar answered Sep 19 '22 06:09

Smartens


Late for the party.. This is what worked for me..

if you want to create a symbolic link from sourceFolder to destinationFolder you should be inside the parent of the destinationFolder "parentOfDestinationFolder" while doing so.

like image 21
Kod Avatar answered Sep 21 '22 06:09

Kod