Skip to content
Monday, October 31, 2005 - 11:23 am ET

HOWTO: Remove a Symbolic Link

This may seem not seem complicated, but if you don’t know, you don’ t know.

When you create a symbolic link, the link file you’ve created just points to the target file. Therefore, the link file has no other purpose in life than that. So, when you want to get rid of it, just delete the link file.


  • Digg
  • StumbleUpon
  • Tumblr


Post a comment
  1. By Erik
    1789 days ago

    Yes, but it may also be helpful to some to understand that the link to a directory is treated as a file, and not as a directory (which it simulates). Therefore, ‘rmdir’ accomplishes nothing. :)


  2. By Jon
    1789 days ago

    Thanks Erik,

    I have never considered creating a symlink to a directory, but why not! Great tip :)


  3. By Mihai
    1773 days ago

    When I run rm may_symbolic_link I get a error message like:

    rm: cannot remove `/destination/folder’: Is a directory

    I don’t want to remove the directory – just the link. Any ideas?


  4. By Jon
    1773 days ago

    Hey Mihai,

    I’m not sure what’s going on there. I took a look at some other sites (like here) and it seems that you should be able to do what you want.

    Anyone else have any ideas?


  5. By bbobbo
    1765 days ago


    unlink symbolic_link

    instead of rm.


  6. By Jon
    1765 days ago

    So easy…damn.

    Thanks bbobbo!


  7. By James
    1761 days ago

    bbobbo, you ‘da Man!!! I NEEDED that! Many thanks!


  8. By Karl
    1689 days ago

    When using the rm or unlink command to remove a symbolic link to a directory, make sure you don’t end the target with a ‘/’ character because it will create an error. Example:

    $ mkdir dirfoo
    $ ln -s dirfoo lnfoo
    $ rm lnfoo/
    rm cannot remove directory ‘lnfoo/’ : Is a directory
    $ unlink lnfoo/
    unlink: cannot unlink ‘lnfoo/’: Not a directory
    $ unlink lnfoo

    Notice how one complains it “Is a directory”, but the other complains it is “Not a directory”, which I found confusing. This is a problem if you have a tendency to use tab completion a lot, because it will stick a ‘/’ at the end.


  9. By Jon
    1688 days ago

    Excellent tip, Karl. Thanks!


  10. By Karthik
    1652 days ago

    Thanks Karl!
    I was having this problem for a long time.


  11. By Andrew
    1622 days ago

    Karl – thanks for your post. I knew to use unlink, but could not for the life of me figure out why it wasn’t working!

    Pesky slashes…


  12. By Gunni
    1600 days ago

    to remove symbolic links try ‘rm -r’


  13. By WarZeg
    1592 days ago

    how about the user how can remove it if you accidentally use “userdel username” instead “userdel -r username”


  14. By Joseph
    1584 days ago

    Great tip on the unlink command.

    Thanks a lot.


  15. By gemini728
    1584 days ago

    OK, none of the above worked for me. My case is a little more complicated. I created a mount point (I guess that is not a link) to an SMB share on a Windows machine on the network. Now, it appears the IP address of the Windows machine has changed, so I cannot get to that directory anymore. I created a new mount point and mapped it to the same machine and SMB share. But I cannot delete the old link/mount-point, or whatever it is considered.

    Any ideas?


  16. By fozner
    1557 days ago

    Serve up a temporary share with the same name on the local machine. Use ifconfig x.x.x.x up to spoof the old IP. Now you can access something that looks like it. Well, it might not be the greatest but it’s an idea…


  17. By Andy
    1458 days ago

    Thanks for the tip Karl! And Gunni, don’t be an ass.


  18. By jafar
    1458 days ago

    Some time you may not be able to unlink or rm. Just renmae the source and then you can remove or unlink. then you can renmae to source to its original name. I hope this help.


  19. By John Cooke
    1394 days ago

    The unlink command worked a treat on a symlinked directory I was having trouble deleting

    many thanks


  20. By TuVahLuh
    1359 days ago

    I tried the unlink after google directed me here….

    I said to my linux…

    unlink ligh (and then pressed tab for autocompletion)

    Then I got:

    unlink: cannot unlink `lighttpd-main/’: Not a directory

    Aha! The trailing slash using autocomplete messes it up. This time get rid of trailing slash and it unlinked just fine.


Post a Comment