# ln -sf doesn't work[SOLVED] Must use ln -sfn dir link_to_dir

## Tuvok

Normally, when symlinking the current kernel tree there stands something

like: you should

cd /usr/src

ln -sf linux-2.6.9-gentoo-r4 linux

But this doesn't work for me (although it should work according to man

page):

tux src # ls -l

total 68

[...]

lrwxr-xr-xï¿½ï¿½ï¿½1ï¿½rootï¿½rootï¿½ï¿½ï¿½ï¿½21ï¿½Novï¿½13ï¿½19:28ï¿½linuxï¿½->ï¿½linux-2.6.9-gentoo-r1

[...]

and I have to remove the target manually.

I searched already on google (and google news), but got no satisfying

results. I found a bug report on debian from 2001 though #95914, but I think this

should have been fixed by now. Switching the order -fs or using the long

option names doesn't help either.

tux src # etcat belongs /bin/ln 

Searching for /bin/ln in * ...

kde-base/kdelibs-3.2.3-r2

kde-base/kdelibs-3.3.1

kde-base/kdeaddons-3.3.1

media-gfx/graphviz-1.10

sys-apps/coreutils-5.2.1

x11-base/xorg-x11-6.7.0-r2

EDIT: according to  comment from uniplex on toralf's bug report, one must use the -n, --no-dereference option in this case, i.e.:

ln -sfn linux-2.6.9-gentoo-r4 linuxLast edited by Tuvok on Wed Nov 17, 2004 10:17 pm; edited 1 time in total

----------

## toralf

IMHO not the right forum, but anyway:

ln -sf seems only to work on files but not on directories, so a 

```
ls -sf foo bar
```

 should work if foo is an ordinary file

----------

## Tuvok

 *toralf wrote:*   

> IMHO not the right forum, but anyway:
> 
> 

 

I saw that this is a forum for "bash programming" and just thought, this behaviour of ln might be noticed by somebody who programs bash. Should it go to "other things gentoo"?

 *toralf wrote:*   

> 
> 
> ln -sf seems only to work on files but not on directories, so a 
> 
> ```
> ...

 

But this notion appears almost everywhere:

see e.g.:

http://www.gentoo.org/doc/en/migration-to-2.6.xml#doc_chap3

Code Listing 3.2: Updating the /usr/src/linux softlink

# cd /usr/src

# ln -sf linux-2.6.9-gentoo-r2 linux

It states "updating" and uses -f option.Last edited by Tuvok on Tue Nov 16, 2004 2:57 pm; edited 1 time in total

----------

## pjp

Doesn't seem to work for me either.

Moved from Portage & Programming.

----------

## Legoguy

You need to remove the original link first....

```

cd /usr/src

rm linux

ln -sf linux-2.6.10-rc2 linux

```

----------

## Tuvok

 *Legoguy wrote:*   

> You need to remove the original link first....
> 
> 

 

I already said that in my first post. But then you do not need the -f option.

----------

## toralf

As a can remember under AIX "ln -sf" did also work for directories not only for files. Might be this is a gentoo specific bug ? Anyway it was time for creating the bug : https://bugs.gentoo.org/show_bug.cgi?id=71500

----------

