Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the js_composer domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/holhol2/public_html/wp-includes/functions.php on line 6121

How Do I Remove a Symbolic Link in Linux?

By holhol24 | June 4, 2021
How Do I Remove a Symbolic Link in Linux?

A symbolic link, also known as symlink, is a file that points to another file. The file points to can be in the same or different directory. It is similar to the shortcuts in Windows OS.

In today’s post, we will be describing how to remove a symbolic link in Linux. Note that removing a symbolic link does not affect the file it points to.

Before removing a file, you can verify whether it is a symbolic link using the ls -l command. It will also show you the file or directory that it points to.

The l in permissions (lrwxrwxrwx) confirms that it’s a symbolic link.

Remove a Symbolic Link using the unlink command

The unlink command is used for removing a single file from the file system. To remove a symbolic link in Linux, type the unlink command followed by the name of the symbolic link and hit Enter:

$ sudo unlink symbolic_link

Replace symbolic_link with the name of the symbolic link you want to remove. After that, you can use the ls -l command to confirm if the symlink has been removed.

Remove a symlink that points to a directory, don’t use the slash after the directory name. Let’ say we want to remove a symbolic link directory named Docs, as shown in the following screenshot:

The command to remove the symlink directory will be:

Remove a Symbolic Link using the rm command

The rm command can also be used to remove a symbolic link. For removing a symbolic link in Linux, type the rm command followed by the name of the symbolic link and hit Enter:

After that, you can use the ls -l command to confirm if the symlink has been removed.

You can also use the -i flag with the rm command to prompt for confirmation.

Removing a symlink that points to a directory, don’t use the slash after the directory name. Let’ say we want to remove a symbolic link directory named Docs, as shown in the following screenshot:

The command to remove the symlink directory will be:

After that, you can use the ls -l command to confirm if the symlink has been removed.

That is all there is to it! You have learned to remove a symbolic link in Linux OS using the unlink and rm command in this post. While removing a symbolic link, make sure only to remove the symbolic link itself, not the file or directory it is linking to.

holhol24

I am a Linux server pro admin and enthusiast, an upcoming web developer, junior php developer. I am currently a content creator for Holhol24, I love to play with Linux and all other distributions of it. I loves working with computers and strongly believes in sharing knowledge. Follow me For more insight into what is happening in Tech.

Advertisement Share: Facebook Twitter WhatsApp

Deprecated: File Theme without comments.php is deprecated since version 3.0.0 with no alternative available. Please include a comments.php template in your theme. in /home/holhol2/public_html/wp-includes/functions.php on line 6121

Leave a Reply

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