LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Failed to create symbolic link (https://www.linuxquestions.org/questions/linux-newbie-8/failed-to-create-symbolic-link-4175446607/)

vitronix 01-21-2013 10:40 AM

Failed to create symbolic link
 
Hello,

Maybe it's a bit odd, being a newbie, but I started with Linux From Scratch.
I've read my Linux books and I don't understand why I caoonot create a symbolic link.
Here's the output:

root@sparrow:/mnt/lfs# ln -sv /tools /
ln: failed to create symbolic link `/tools': File exists

I looked in the root directory but there is no link there.

Can anyone explain?

Thanks in advance.

divyashree 01-21-2013 10:56 AM

You should give a file name to the symboliclink for /tools. Otherwise it will be an infiniteloop symbolic link.

e.g

Quote:

ln -sv /tools /tools1

shivaa 01-21-2013 11:08 AM

As per manual of ln, syntax is:

Code:

ln [OPTION]... [-T] TARGET LINK_NAME  (1st form)
ln [OPTION]... TARGET                      (2nd form)
ln [OPTION]... TARGET... DIRECTORY    (3rd form)
ln [OPTION]... -t DIRECTORY TARGET...  (4th form)
.....
.....

Or in simple form,
Code:

ln [option] source_dir linkname
So in order to create a link of /tools, do it as:-
Code:

~$ ln -s /tools <linkname>
~$ ls -l linkname
...... linkname -> /tools


suicidaleggroll 01-21-2013 11:14 AM

The problem is you're telling it to create a link to /tools in /. Since you didn't give it a name, it will use the name of the target, which is tools. So essentially the command you're issuing is:
ln -sv /tools /tools

The error is because it can't create a link called /tools because a file of that name already exists (it also happens to be the one you're trying to link to, which if the command went through would be replaced by a link pointing to itself).

vitronix 01-21-2013 05:33 PM

Solved
 
Quote:

Originally Posted by vitronix (Post 4874764)
Hello,

Maybe it's a bit odd, being a newbie, but I started with Linux From Scratch.
I've read my Linux books and I don't understand why I caoonot create a symbolic link.
Here's the output:

root@sparrow:/mnt/lfs# ln -sv /tools /
ln: failed to create symbolic link `/tools': File exists

I looked in the root directory but there is no link there.

Can anyone explain?

Thanks in advance.

I'm sorry to have waisted your time, but somehow I created a directory tools.
After removing this directory the command works

shivaa 01-21-2013 09:18 PM

:)
 
Good, then mark the thread as solved (on top menu, select Thread Tools option and Mark this thread as solved).


All times are GMT -5. The time now is 08:02 AM.