# am i too silly to use "ln" ? [solved]

## alex.blackbit

hello everybody

maybe i am just an idiot, but i cannot find out what i do wrong:

```
alexbook src # ls -l

insgesamt 12K

lrwxrwxrwx   1 root root   14 22. Sep 12:05 linux -> linux-2.6.13.1/

drwxr-xr-x  18 root root 4,0K 14. Sep 17:38 linux-2.6.11.8/

drwxr-xr-x  19 root root 4,0K  4. Okt 19:43 linux-2.6.13.1/

drwxr-xr-x  18 root root 4,0K  4. Okt 19:42 linux-2.6.13.2/

alexbook src # ln -sf linux-2.6.13.2 linux

alexbook src # ls -l

insgesamt 12K

lrwxrwxrwx   1 root root   14 22. Sep 12:05 linux -> linux-2.6.13.1/

drwxr-xr-x  18 root root 4,0K 14. Sep 17:38 linux-2.6.11.8/

drwxr-xr-x  19 root root 4,0K  4. Okt 19:45 linux-2.6.13.1/

drwxr-xr-x  18 root root 4,0K  4. Okt 19:42 linux-2.6.13.2/

alexbook src #
```

why does the symlink still point to 13.1 ?

shouldn't the -f take care of the existing destination?

can anyone please tell me what i do wrong?Last edited by alex.blackbit on Wed Oct 05, 2005 1:26 pm; edited 1 time in total

----------

## Monkeh

I've had it do that to me too.. Only thing I can think of (and likely nothing to do with it), is it does it on ReiserFS not but EXT3. Anyway, just rm the link and create it again.

----------

## alex.blackbit

the filesystem where these things are is xfs

can this be the problem?

----------

## Monkeh

I dunno. I don't know enough about filesystems to know if they could possibly be the cause of this.

----------

## beatryder

I use reiserfs and I have to delete the current link and re-create it, another option you have is

```

# USE="symlink" emerge <your favourite source tree>

```

Which will take care of the symlinking for you

----------

## Gogiel

 :Shocked:   :Laughing:   :Laughing: 

Just rm linux and link it again. What's the problem?

----------

## Monkeh

 *Gogiel wrote:*   

>   
> 
> Just rm linux and link it again. What's the problem?

 

The fact that standard syntax fails to work. It's not really a problem, but I'd certainly like to know why I can't use ln properly.

----------

## Raistlin

 *Gogiel wrote:*   

>   
> 
> Just rm linux and link it again. What's the problem?

 

```
$>man ls

...

       -f, --force

              Remove existing destination files.

```

That's the problem. This must not happen!

----------

## Raistlin

Otherwise the following would be "ok", too:  *Quote:*   

> "oh, you know, my system became unstable..."
> 
> "Yes, so what have you done?"
> 
> "I've just fixed it: I've reinstalled the complete OS - now it works"

 

(Unbelievable, but there are some people out there with some so-called OS-es that really act that way   :Shocked:   :Shocked:   :Wink:  )

----------

## Monkeh

It seems to be filesystem specific. It did this to me during install on ReiserFS, but it's always worked perfectly with EXT3. There's another thing to add to my list of reasons to not use ReiserFS in the future..

----------

## Raistlin

I'm not sure if the experiences one had with ReiserFS also apply to ReiserFS4...

----------

## Monkeh

I'm not even considering 4, I never have and probably never will..

----------

## Raistlin

 :Rolling Eyes:  Maybe I already have a project for the weekend: convert the data drive for my vdr back from reiser to ext3 again...

----------

## dgaffuri

I've ext3. Do you guess what's happening?

```
src # ls -l

total 240

lrwxrwxrwx   1 root root     22 Sep 12 01:13 linux -> linux-2.6.13-gentoo-r1

drwxr-xr-x  19 root root   4096 Oct  5 00:53 linux-2.6.13-gentoo-r1

drwxr-xr-x  19 root root   4096 Sep 22 00:14 linux-2.6.13-gentoo-r2

src # ln -sf linux-2.6.13-gentoo-r2 linux

src # ls -l

total 240

lrwxrwxrwx   1 root root     22 Sep 12 01:13 linux -> linux-2.6.13-gentoo-r1

drwxr-xr-x  19 root root   4096 Oct  5 00:57 linux-2.6.13-gentoo-r1

drwxr-xr-x  19 root root   4096 Sep 22 00:14 linux-2.6.13-gentoo-r2
```

----------

## hpestilence

 *dgaffuri wrote:*   

> I've ext3. Do you guess what's happening?
> 
> ```
> src # ls -l
> 
> ...

 

See if adding the rm -iv linux line helps

----------

## JSharku

I think it's a bit of a bug in ln or maybe a misnomer in the man page, and it took me a good while to figure it out too, until I saw the use of the -n option somewhere around here. What it does is tell ln not to follow the symlink first before creating a new link.

```
ln -sf linux-2.6.13.2 linux
```

 results in

```
<whatever dir linux was pointing at before>/linux --> linux-2.6.13.2
```

of course this is a dead link due to the old dir not containing a 2.6.13.2 dir.

```
ln -sfn  linux-2.6.13.2 linux
```

 produces the desired result. Very confusing until you get the hang of it.

Sharku

----------

## alex.blackbit

yes! adding the option -n does the trick (at least for me on xfs)

thanks for the hint!

```
alexbook src # ls -l

insgesamt 12K

lrwxrwxrwx   1 root root   15  4. Okt 20:12 linux -> linux-2.6.13.2/

drwxr-xr-x  18 root root 4,0K 14. Sep 17:38 linux-2.6.11.8/

drwxr-xr-x  19 root root 4,0K  4. Okt 19:45 linux-2.6.13.1/

drwxr-xr-x  19 root root 4,0K  4. Okt 21:07 linux-2.6.13.2/

alexbook src # ln -sfn linux-2.6.13.1 linux

alexbook src # ls -l

insgesamt 12K

lrwxrwxrwx   1 root root   14  5. Okt 15:16 linux -> linux-2.6.13.1/

drwxr-xr-x  18 root root 4,0K 14. Sep 17:38 linux-2.6.11.8/

drwxr-xr-x  19 root root 4,0K  4. Okt 19:45 linux-2.6.13.1/

drwxr-xr-x  19 root root 4,0K  4. Okt 21:07 linux-2.6.13.2/

alexbook src # ln -sfn linux-2.6.13.2 linux

alexbook src # ls -l

insgesamt 12K

lrwxrwxrwx   1 root root   14  5. Okt 15:16 linux -> linux-2.6.13.2/

drwxr-xr-x  18 root root 4,0K 14. Sep 17:38 linux-2.6.11.8/

drwxr-xr-x  19 root root 4,0K  4. Okt 19:45 linux-2.6.13.1/

drwxr-xr-x  19 root root 4,0K  4. Okt 21:07 linux-2.6.13.2/

alexbook src #
```

----------

## JSharku

No problem. I don't think it's fs-related though, just some weirdness in ln itself.

Sharku

----------

## Monkeh

Interesting. I know I've used -sf successfully in the past.. Must've been doing things a little differently than normal (it was months ago, and my memory is quite useless).

----------

