How To Remove Symbolic Links In Linux? – POFTUT

How To Remove Symbolic Links In Linux?

Symbolic links provides practical solutions file name or path related problems. Symbolic links will create same file or folder with different name and path. In some situations this may cause problem and we have to remove and delete symbolic link.

List Symbolic Links

We can start by listing existing links especially symbolic links with ls command like below. Symbolic links provide some redirect to the source file like symbolic link RealInput.

$ ls -lh
List Symbolic Links
List Symbolic Links

Remove Symbolic Links

There are different ways to remove symbolic link. We can just issue rm command to the link file. In this example we will remote link named RealInput .

$ rm RealInput

Remove with unlink Command

As we use ln command which is shortcut for link we have also command named unlinkwhich can unlink given links. In this example we can remove RealInput like below. unlink command is an alias for rm command.

$ unlink RealInput

Remove Symbolic Links with sudo for “Permission Denied” Error

Some symbolic links may be created by privileged user like root . If we try to remove this links with regular or less privileged user we will get an error like permission denied . So in order to remove this symbolic links we need to provide sudo command at the beginning of the command like below.

$ sudo rm RealInput

Remove Hard Links

We can easily remove hard links with the same commands too.

$ unlink RealInput


$ rm RealInput

LEARN MORE  Linux Directory and File Operations

1 thought on “How To Remove Symbolic Links In Linux?”

Leave a Comment