Why are my links going in the wrong place?
Colin Law
clanlaw at googlemail.com
Tue Dec 28 15:33:36 UTC 2010
On 28 December 2010 15:26, Dotan Cohen <dotancohen at gmail.com> wrote:
> For some reason it seems that symbolic links are being created in the
> target directory, instead of the current directory. Why? What am I
> doing wrong?
>
> For instance, I am in a directory with a single subdirectory, in which
> there exists a single file:
> ✈ecd:test$ ls -l
> total 0
> drwxr-xr-x 2 dotancohen dotancohen 16 2010-12-28 17:14 target
> ✈ecd:test$ ls -l target/
> total 4
> -rw-r--r-- 1 dotancohen dotancohen 15 2010-12-28 17:14 file
>
> Now I create a symbolic link in the current directory to the subdirectory:
> ✈ecd:test$ ln -s link target/
>
> But it gets placed in the subdirectory instead of in the current directory:
> ✈ecd:test$ ls -l
> total 0
> drwxr-xr-x 2 dotancohen dotancohen 24 2010-12-28 17:15 target
> ✈ecd:test$ ls -l target/
> total 4
> -rw-r--r-- 1 dotancohen dotancohen 15 2010-12-28 17:14 file
> lrwxrwxrwx 1 dotancohen dotancohen 4 2010-12-28 17:15 link -> link
>
> Even when I explicitly state "current directory" the system tries to
> put the link in the subdirectory (the target directory):
> ✈ecd:test$ ln -s ./link target/
> ln: creating symbolic link `target/link': File exists
> ✈ecd:test$
>
> Why? What am I doing wrong?
I think if you look at man ln you will see that it is doing what you are asking
SYNOPSIS
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)
DESCRIPTION
In the 1st form, create a link to TARGET with the name
LINK_NAME. In the 2nd form, create a link to TARGET in
the current directory. In the 3rd and 4th forms, create links
to each TARGET in DIRECTORY. Create hard links
by default, symbolic links with --symbolic. When creating hard
links, each TARGET must exist. Symbolic links
can hold arbitrary text; if later resolved, a relative link is
interpreted in relation to its parent direc‐
tory.
You are using the 3rd form so it puts a link to TARGET in DIRECTORY.
I think maybe you want the params the other way around.
Colin
More information about the ubuntu-users
mailing list