[lug] Odd Problem with rm and Symbolic Links

Lee Woodworth blug-mail at duboulder.com
Sun Dec 29 09:41:18 MST 2013


IIRC, at one point these:
     ln -s /etc   /tmp/x
     ln -s /etc/  /tmp/y
were treated differently by rm. It would complain that
/tmp/y was a directory. I think that unlink /tmp/y
might have been required.

On 12/29/2013 07:38 AM, Davide Del Vento wrote:
> That's right. And not only for rm but for all commands. Some commands then
> ignore the difference, but there is one. Also do note that ls does not
> ignore it. Try
>
> ls <your favorite options> link
>
> vs
>
> ls <your favorite options> link/
>
> Note that the options must be the same to see the difference, since -d
> changes the behavior of ls.
>
> Cheers,
> Davide
>
>
> On Sat, Dec 28, 2013 at 8:38 PM, Orion Poplawski <orion at cora.nwra.com>wrote:
>
>> On 12/28/2013 06:53 PM, stimits at comcast.net wrote:
>>
>>> I'm using Fedora 19, fully updated. I'd created a symbolic link with "ln
>>> -s <real> <symbolic>", but ls -ld shows this as a directory, while a
>>> simple ls -a --color=auto shows that this is indeed a symbolic link, and
>>> if I use "ls -l" from the parent the output indicates it is a soft link
>>> and where the link goes.
>>>
>>> rm fails. If I go to "rm <link>" it tells me this is a directory...so
>>> apparently ls -ld and rm agree, but ls -a --color=auto and ls -l from
>>> parent DISagree with rm. If I use "rm -f <link>", it refuses, because it
>>> is a directory.
>>>
>>> If I use "rmdir <link>", it also refuses, because it is NOT a directory!
>>>
>>> My only success is to "rm -Rf" the link. Sadly, this removes all of the
>>> subdirectories the link pointed at...removing a symbolic link should not
>>> remove what it points at! What gives? Was rm or the use of symbolic link
>>> written to a different standard than I'm used to? Is there some new way
>>> in fedora to remove a symbolic link without removing what it points to?
>>> I have a backup of what it removed, but something seems drastically wrong.
>>>
>>> Both rm and ln are provided by rpm coreutils-8.21-11.fc19.x86_64.
>>> Filesystem is a single partition with ext4. Kernel is current
>>> 3.12.5-200.fc19.x86_64.
>>>
>>>
>>
>> be aware that:
>>
>> rm link/
>>
>> and
>>
>> rm link
>>
>> are different.  Tab-completion (which adds the /) can be an issue here.
>>
>>
>> --
>> Orion Poplawski
>> Technical Manager                     303-415-9701 x222
>> NWRA/CoRA Division                    FAX: 303-415-9702
>> 3380 Mitchell Lane                  orion at cora.nwra.com
>> Boulder, CO 80301              http://www.cora.nwra.com
>> _______________________________________________
>> Web Page:  http://lug.boulder.co.us
>> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
>>
>
>
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: irc.hackingsociety.org port=6667 channel=#hackingsociety
>



More information about the LUG mailing list