There are cases where you need to remove a symbolic link, and avoid its contents.
To remove a symbolic link, you would want to pass it through the "rm" command. To safely remove the link, you should ensure that your "rm" command is interactive such that you can verify that you are removing a link and not the contents that it is linked to. For example, say that we have the following link:
[root@cl ~]# stat mysqltest
File: ‘mysqltest’ -> ‘/var/lib/mysql’
Size: 14 Blocks: 0 IO Block: 4096 symbolic link
Device: fd01h/64769d Inode: 2683778 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-01-05 13:17:02.713091127 -0600
Modify: 2021-01-05 13:17:01.666083752 -0600
Change: 2021-01-05 13:17:01.666083752 -0600
With this link "mysqltest" in mind, we pass it to the "rm" command:
[root@cl ~]# rm -i mysqltest
rm: remove symbolic link ‘mysqltest’?
From this output, you will see that the link is detected. You should only pass the name of the link without any trailing slashes. If a trailing slash is given to the "rm" command, then the directory contents are listed instead. As this is the case, do not use a trailing slash in your command:
[root@cl ~]# rm -i mysqltest/
rm: cannot remove ‘mysqltest/’: No such file or directory
For safety purposes, please ensure that you do not use the "-f" flag in "rm".