Linux – How to remove a Symbolic Link (Softlink)

remove a Symbolic Link

Under Linux, Symbolik Link is a great feature. This feature also exists in Windows.

In this post I will show you how to remove a Symbolic Link (safely) in Linux.

There are two commands, the first, the most know is the command rm, the second is the command unlink (a cool and secure command).

Don't worry the command rm don't remove your original file/directory, the rm command just removes the Symbolic Link.

For example, I would like to remove the link “link_to_original”


florian@linux-desktop:~/Documents$ ls -lh
total 28K
drwxr-xr-x 5 florian florian 4,0K avril 24 22:07 Ansible
drwxrwxr-x 3 florian florian 4,0K avril 20 22:36 import
lrwxrwxrwx 1 florian florian    9 avril 26 21:03 link_to_original -> original/
drwxrwxr-x 2 florian florian 4,0K avril 26 21:03 original

Use the command rm :


florian@linux-desktop:~/Documents$ rm ./link_to_link

Use the command unlink :


florian@linux-desktop:~/Documents$ unlink ./link_to_link

The both commands work fine with a symbolic link associated to a file or a directory.

 

 

florian

Hi, I'm Florian and I'm 32 years old. I have discover IT at 17, and i had my first internet connection at 23. So i'm not going to say that i was very precocious in this domain... PS : I 'm French, so please, be lenient with my english ;)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.