LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cannot remove symbolic link to directory. (https://www.linuxquestions.org/questions/linux-newbie-8/cannot-remove-symbolic-link-to-directory-117786/)

martint 11-19-2003 08:48 AM

Cannot remove symbolic link to directory.
 
I have
~/dir1/dir2
and created a symbolic link to dir2:
ln -s ~/dir1/dir2 ~/symlink

Now I can't remove symlink! I get the errors:

$rm symlink/
rm: cannot remove directory 'testsymboliclink/': Is a directory
$rmdir symlink/
rmdir: 'testsymboliclink/': Not a directory

This is REALLY weird. I even cannot

$unlink symlink/
unlink: 'testsymboliclink/': Not a directory

I can't even remove the link, if the dir is empty. Please help me...

Lostman 11-19-2003 08:52 AM

Just use the remove dir command for the link dir. I assume that link is in a different dir, so just

rmdir /path/to/where/the/link/is

martint 11-19-2003 09:26 AM

I think you dont understand my problem:

When I use rm, it says "Is a directory"
When I use rmdir, it says "Not a directory"
Thats quite absurd...

I've tried to use both relative and absolute paths, none of them works.

Mikhail_16 11-19-2003 02:51 PM

DUDE, its
'rm symlink' (without '/' on the end)

martint 11-19-2003 06:43 PM

Ahh, thanks!
That must be the first (and last) disadvantage of _tab-completion_ :-)

DrDom 03-24-2007 02:50 AM

It's all in the completion...
 
If you do "rm target/", then rm assumes target is a directory without doing any further checking.

Someone should patch rm to remove this stupid behavior...

XOX DOM

aplusplus 09-17-2014 08:45 PM

Quote:

Originally Posted by Lostman (Post 608726)
Just use the remove dir command for the link dir. I assume that link is in a different dir, so just

rmdir /path/to/where/the/link/is

Thank you! This really works.


All times are GMT -5. The time now is 03:19 PM.