Skip to main content
How To

Remove Symlink From Ubuntu Linux

Wondering how to remove soft links from your system? Use the rm command. Yes, that's it. Here's how!

Sagar Sharma

In Linux, creating symbolic links is quite easy but what if you want to remove them?

There is an unlink command. But it is not dedicated to links. It is used for removing files as well as link.

In fact, you can use the good old reliable rm command to delete the links.

rm link_name

Let me show how you can use the rm command to remove symbolic links.

The rm command is mainly used to remove files from Linux but it can also be used to remove symbolic links.

How? Just follow the given simple syntax:

rm sym_link_or_path_to_symlink

Don't know how to find the symbolic link? You can use the ls or tree command:

find symbolic link in linux

As you can see, my symlink is Linuxmint which is pointing to /home/sagar/Tutorial/LinuxMint.iso.

So if I were to remove a Linuxmint symbolic link, then, I'd have to use the following command:

rm Linuxmint
remove symbolic link in ubuntu linux

To remove multiple symlinks, all you have to do is append multiple symbolic filenames:

rm symlink1 symlink2 symlink3

Here, I have two symbolic links: Linuxmint and Pop-OS:

list symbolic links in linux

So if I want to remove both at once, I'd have to use the following command:

rm Linuxmint Pop-OS
remove multiple symbolic links at once in Ubuntu linux

You can create a symlink to a directory so what about removing it? Well, the syntax is the same as you did with files:

rm symlink_to_dir

Remember, never use / while removing the symbolic link to the directory or it will throw the following error:

cannot remove: Is a directory error while removing the symbolic link

So let's say I want to remove the ISO symlink which is pointing to another directory. Then I will be using the following:

rm ISO
remove symbolic link pointing to a directory

You may have created a hard link and want to remove it.

First, it is almost impossible to distinguish between a normal file and a hard link. To do so, you'd have to pay attention to the inode number as it points to the data block so it will be the same as the original file.

Here, I have created a hard link which is pointing to the file in the same directory so I can show the inode numbers easily:

use ls command in Ubuntu

Once you find the symbolic link, you can use the rm command to remove it:

rm Hard-link

And it should remove it!

Softlinks are cool but did you know that hard link directly points to the storage block so even if you remove the file, you can still use the hard link to access the data?

There's more to it. And if you're interested, you can refer to our detailed guide:

Hard Link in Linux: Everything Important You Need to Know
Learn the concept of hard links in Linux and its association with inodes in this tutorial.

I hope you will find this guide helpful. And if you have any queries, feel free to ask in the comments.

Sagar Sharma