-
why doesn't ln -sf work?
I've noticed in that a lot of times ln -sf does not work. for example:
Code:
root@JT-Linux-Server root # cd /usr/src/
root@JT-Linux-Server src # ls -l
total 8
lrwxrwxrwx 1 root root 19 Nov 18 03:22 linux -> linux-2.4.20-xfs-r3
drwxr-xr-x 17 root root 4096 Dec 3 11:37 linux-2.4.20-xfs-r3
drwxr-xr-x 17 root root 4096 Dec 3 10:28 linux-2.4.20-xfs-r4
root@JT-Linux-Server src # ln -sf linux-2.4.20-xfs-r4/ linux
root@JT-Linux-Server src # ls -l
total 8
lrwxrwxrwx 1 root root 19 Nov 18 03:22 linux -> linux-2.4.20-xfs-r3
drwxr-xr-x 17 root root 4096 Dec 3 11:49 linux-2.4.20-xfs-r3
drwxr-xr-x 17 root root 4096 Dec 3 10:28 linux-2.4.20-xfs-r4
Why doesn't this work? I've tried every combination of adding leading slashes, but it still doesn't work. For example:
ln -sf linux-2.4.20-xfs-r4 linux
ln -sf linux-2.4.20-xfs-r4/ linux
ln -sf linux-2.4.20-xfs-r4 linux/
ln -sf linux-2.4.20-xfs-r4/ linux/
ln -s -f linux-2.4.20-xfs-r4/ linux
Still nothing. I read straight from the ln man page:
-f, --force
Remove existing destination files.
Even when I used -i it didn't work. There is a way to make a new symlink without manually rm-ing the original symlink, right?
-
nope, you have to delete the original first.
-
if I have to delete it manually, then what does -f or --force do? What's it used for then?
-
Re: why doesn't ln -sf work?
sharth@mini-sharth:~/blah$ ln -sf linux os
sharth@mini-sharth:~/blah$ ls -l os
lrwxrwxrwx 1 sharth sharth 5 Dec 3 15:29 os -> linux
sharth@mini-sharth:~/blah$ ln -sf new-destination os
sharth@mini-sharth:~/blah$ ls -l os
lrwxrwxrwx 1 sharth sharth 15 Dec 3 15:29 os -> new-destination
sharth@mini-sharth:~/blah$ ln -s -f even-newer os
sharth@mini-sharth:~/blah$ ls -l os
lrwxrwxrwx 1 sharth sharth 10 Dec 3 15:29 os -> even-newer
sharth@mini-sharth:~/blah$ ln --version
ln (coreutils) 5.0
Written by Mike Parker and David MacKenzie.
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
sharth@mini-sharth:~/blah$
irc.freenode.net #justlinux The Not So Official JL IRC Channel.
¤ Debian ¤ Apt-Get ¤
-
I think the -f pertains to individual files only. In the example you provided, it shows that you are trying to link directories. I'll bet that if you just created some files and did the same thing it would work. Not necessarily the same case with directories, I presume.
EVAC
-
Originally posted by evac-q8r
I think the -f pertains to individual files only. In the example you provided, it shows that you are trying to link directories. I'll bet that if you just created some files and did the same thing it would work. Not necessarily the same case with directories, I presume.
EVAC
yep. didn't work with directories.. use -snf
irc.freenode.net #justlinux The Not So Official JL IRC Channel.
¤ Debian ¤ Apt-Get ¤
-
but doing
ln -s madeup/ crap
works fine. I'm still not sure what -f is for.
-
-f is needed to replace the file if they are files themselves...
-n makes ln not care if its dealing with directories or files.
irc.freenode.net #justlinux The Not So Official JL IRC Channel.
¤ Debian ¤ Apt-Get ¤
-
Perfect! Thank you so much, I'm going to sleep a lot better tonight thanks to you!
Here I am making it work:
jt@JT-Linux-Laptop jt $ echo poop > crap.txt
jt@JT-Linux-Laptop jt $ ln -sf madeup crap.txt
jt@JT-Linux-Laptop jt $ ls -l
lrwxrwxrwx 1 jt users 6 Dec 3 13:14 crap.txt -> madeup
But shouldn't it overwrite a symlink too? I guess it would make sense to, but it just doesn't...
I'm so anal, I'm probably gonna go search for a patch or try to decrypt C code.
-
-
Nobody else thinks that ln -sf crap poop should overwrite the poop symbolic link when invoked? I think it just makes sense.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|