Unable to unlink a file linux

Posted on

Problem :

I have a link file as below

    testlnk -> /home/wemohamm/Desktop/script

But I am unable to delete the link.
If I use rm testlnk, I get error

rm: cannot remove `testlnk/': Is a directory

If I user rmdir testlnk I get error

rm: cannot remove `testlnk/': Is a directory

When I use rm -rf, it deleted the contents of /home/wemohamm/Desktop/script

Finally unlink command throws this error

unlink: cannot unlink `testlnk/': Not a directory

Solution :

Something that ends with a / must be directory. You can’t rm directory. You can remove the link, but the link is called testlink, not testlink/ (which is the directory you get when you follow the link).

Leave a Reply

Your email address will not be published. Required fields are marked *