Re: Changing the symbolic link for /Centos/5

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, Jun 26, 2008 at 10:05:11AM +1000, Gavin Carr wrote:
> On Wed, Jun 25, 2008 at 07:15:00AM -0400, William L. Maltby wrote:
> > 
> > On Wed, 2008-06-25 at 03:48 -0500, Johnny Hughes wrote:
> > > Robert Moskowitz wrote:
> > > > I do not know the command line for symbolic links.  I created the 
> > > > symbolic link of /Centos/5 to /Centos/5.1 in Nautilus which does not 
> > > > have a method of changing a symbolic link.  Only deleting it and 
> > > > creating a new one.
> > > > 
> > > 
> > > Not that I know of, I always just delete an recreate it using "rm -f" 
> > > and "ln -s" at the command line.
> > 
> > It used to be that the -f worked. Sometime in the past that disappeared.
> > Bad decision, IMHO.
> 
> It's still there:
> 
>   nox:~/tmp/ln$ touch foo
>   nox:~/tmp/ln$ touch bar
>   nox:~/tmp/ln$ ln -s foo baz
>   nox:~/tmp/ln$ ll
>   total 12
>   -rw-r--r-- 1 gavin gavin 0 Jun 26 10:06 bar
>   lrwxrwxrwx 1 gavin gavin 3 Jun 26 10:06 baz -> foo
>   -rw-r--r-- 1 gavin gavin 0 Jun 26 10:06 foo
>   nox:~/tmp/ln$ ln -sf bar baz
>   nox:~/tmp/ln$ ll
>   total 12
>   -rw-r--r-- 1 gavin gavin 0 Jun 26 10:06 bar
>   lrwxrwxrwx 1 gavin gavin 3 Jun 26 10:06 baz -> bar
>   -rw-r--r-- 1 gavin gavin 0 Jun 26 10:06 foo
> 
> 
> It does seem to be flaky though. I definitely have had times it hasn't
> worked recently.

If there's already a link to a directory, you need -n (usually);

       -n, --no-dereference
            treat destination that is a symlink to a directory as if
            it were a normal file

Otherwise, you'll end up with a rogue link inside the existing directory:

mikaelf@mikaelf:/tmp/ln$ ln -sf foo link
mikaelf@mikaelf:/tmp/ln$ ls -lR
.:
total 8
drwxr-xr-x 2 mikaelf mikaelf 4096 2008-06-26 11:19 bar
drwxr-xr-x 2 mikaelf mikaelf 4096 2008-06-26 11:16 foo
lrwxrwxrwx 1 mikaelf mikaelf    3 2008-06-26 11:19 link -> bar

./bar:
total 0
lrwxrwxrwx 1 mikaelf mikaelf 3 2008-06-26 11:19 foo -> foo

./foo:
total 0

--
Fridh
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux